#include <bits/stdc++.h>
using namespace std;
const long long S[] = {2, 7, 13, 20, 59, 66, 243, 250, 979, 986, 3923, 3930, 15699, 15706, 62803, 62810, 251219, 251226, 1004883, 1004890, 4019539, 4019546, 16078163, 16078170, 64312659, 64312666, 257250643, 257250650, 1029002579, 1029002586, 4116010323, 4116010330};
const long long Z[] = {2, 9, 22, 42, 101, 167, 410, 660, 1639, 2625, 6548, 10478, 26177, 41883, 104686, 167496, 418715, 669941, 1674824, 2679714, 6699253, 10718799, 26796962, 42875132, 107187791, 171500457, 428751100, 686001750, 1715004329, 2744006915, 6860017238, 10976027568};
bool recur(int i, long long s) {
if(s==0)
return true;
if(i<0 || s<0 || s>Z[i])
return false;
int j = i-1;
while(j>0 && S[j]>s-S[i]) j--;
bool b = recur(j, s-S[i]);
if(!b) b = recur(i-1, s);
return b;
}
int main() {
int T;
long long N;
cin >> T;
while(T--) {
cin >> N;
cout << (recur(31, N) ? "YES\n" : "NO\n");
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgpjb25zdCBsb25nIGxvbmcgU1tdID0gezIsIDcsIDEzLCAyMCwgNTksIDY2LCAyNDMsIDI1MCwgOTc5LCA5ODYsIDM5MjMsIDM5MzAsIDE1Njk5LCAxNTcwNiwgNjI4MDMsIDYyODEwLCAyNTEyMTksIDI1MTIyNiwgMTAwNDg4MywgMTAwNDg5MCwgNDAxOTUzOSwgNDAxOTU0NiwgMTYwNzgxNjMsIDE2MDc4MTcwLCA2NDMxMjY1OSwgNjQzMTI2NjYsIDI1NzI1MDY0MywgMjU3MjUwNjUwLCAxMDI5MDAyNTc5LCAxMDI5MDAyNTg2LCA0MTE2MDEwMzIzLCA0MTE2MDEwMzMwfTsKY29uc3QgbG9uZyBsb25nIFpbXSA9IHsyLCA5LCAyMiwgNDIsIDEwMSwgMTY3LCA0MTAsIDY2MCwgMTYzOSwgMjYyNSwgNjU0OCwgMTA0NzgsIDI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