#include <bits/stdc++.h>
using namespace std;
const int li = 15485863;
bool isp[li + 1];
long long pr[li], ps[li + 1];
void prse() {
fill(isp, isp + li + 1, true);
isp[0] = isp[1] = false;
int cnt = 0;
for (int i = 2; i <= li; i++) {
if (isp[i]) {
pr[cnt++] = i;
for (int j = i * 2; j <= li; j += i)
isp[j] = false;
}
}
for (int i = 0; i < cnt; i++) {
ps[i + 1] = ps[i] + pr[i];
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
freopen("nguyento.inp", "r", stdin);
freopen("nguyento.out", "w", stdout);
prse();
int te;
cin >> te;
while (te--) {
int n;
cin >> n;
cout << ps[n] << "\n";
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgpjb25zdCBpbnQgbGkgPSAxNTQ4NTg2MzsKYm9vbCBpc3BbbGkgKyAxXTsKbG9uZyBsb25nIHByW2xpXSwgcHNbbGkgKyAxXTsKCnZvaWQgcHJzZSgpIHsKICAgIGZpbGwoaXNwLCBpc3AgKyBsaSArIDEsIHRydWUpOwogICAgaXNwWzBdID0gaXNwWzFdID0gZmFsc2U7CiAgICBpbnQgY250ID0gMDsKICAgIGZvciAoaW50IGkgPSAyOyBpIDw9IGxpOyBpKyspIHsKICAgICAgICBpZiAoaXNwW2ldKSB7CiAgICAgICAgICAgIHByW2NudCsrXSA9IGk7CiAgICAgICAgICAgIGZvciAoaW50IGogPSBpICogMjsgaiA8PSBsaTsgaiArPSBpKQogICAgICAgICAgICAgICAgaXNwW2pdID0gZmFsc2U7CiAgICAgICAgfQogICAgfQogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBjbnQ7IGkrKykgewogICAgICAgIHBzW2kgKyAxXSA9IHBzW2ldICsgcHJbaV07CiAgICB9Cn0KCmludCBtYWluKCkgewogICAgaW9zOjpzeW5jX3dpdGhfc3RkaW8oZmFsc2UpOwogICAgY2luLnRpZShudWxscHRyKTsKICAgIGZyZW9wZW4oIm5ndXllbnRvLmlucCIsICJyIiwgc3RkaW4pOwogICAgZnJlb3Blbigibmd1eWVudG8ub3V0IiwgInciLCBzdGRvdXQpOwoKICAgIHByc2UoKTsKICAgIGludCB0ZTsKICAgIGNpbiA+PiB0ZTsKICAgIHdoaWxlICh0ZS0tKSB7CiAgICAgICAgaW50IG47CiAgICAgICAgY2luID4+IG47CiAgICAgICAgY291dCA8PCBwc1tuXSA8PCAiXG4iOwogICAgfQogICAgcmV0dXJuIDA7Cn0KCg==