/**/
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#include <queue>

typedef long long LL;
using namespace std;

int t, n;

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);

	scanf("%d", &t);
	while(t--){
		scanf("%d", &n);
		int x1 = n / 150, x2 = n / 200, x3 = n / 350;
		int ans = 10000;
		for (int i = 0; i <= x1; i++){
			for (int j = 0; j <= x2; j++){
				for (int k = 0; k <= x3; k++){
					if(i * 150 + j * 200 + k * 350 > n) continue;
					ans = min(ans, n - i * 150 - j * 200 - k * 350);
				}
			}
		}
		printf("%d\n", ans);
	}

	return 0;
}
/**/