#include <bits stdc++.h> using namespace std; int v[10] = {1, 6, 28, 88, 198, 328, 648}, e[10] = {8, 18, 28, 58, 128, 198, 388}; int main() { int T, n; scanf("%d", &T); while (T--) { scanf("%d", &n); int res = 0; for (int i = 0; i < (1 << 7); ++i) { int t = 0, s = 0; for (int j = 0; j < 7; ++j) if (i >> j & 1) s += v[j], t += e[j]; if (s <= n) res = max(res, t + n * 10); } printf("%d\n", res); } return 0; }