#include <iostream>
#include <vector>
#define ll long long
using namespace std;
ll k;
vector<int> vec = {3, 5, 9, 15, 21, 25, 27};
void solve() {
    cin >> k;
    cout << ((k-1) / 7) * 30 + vec[(k - 1) % 7] << endl;
    return;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t;cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}