#include <iostream>
#define LL long long
using namespace std;
LL N,res; int T;
int main(){
cin >> T;
LL aux,f1,f2,l,i;
while (T--){
cin >> N;
res=0;
f1=1,f2=1;
while (f2+f1<=N){
l=-1;
for (i=1; i*i<=N/f2 || (N-f2*i)/(f1*i)==l; i++) l=(N-f2*i)/(f1*i),res+=l;
for (i=1; i<l; i++) res+=i*(N/(i*f1+f2)-N/((i+1)*f1+f2));
aux=f1+f2;
f1=f2,f2=aux;
}
for (i=1; i*i<=N || l==N/i; i++) res+=N/i,l=N/i;
for (i=1; i<l; i++) res+=i*(N/i-N/(i+1));
cout << res << "\n";
}
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojZGVmaW5lIExMIGxvbmcgbG9uZwp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKTEwgTixyZXM7IGludCBUOwoKaW50IG1haW4oKXsKICAgIGNpbiA+PiBUOwoKICAgIExMIGF1eCxmMSxmMixsLGk7CiAgICB3aGlsZSAoVC0tKXsKICAgICAgICBjaW4gPj4gTjsKCiAgICAgICAgcmVzPTA7CiAgICAgICAgZjE9MSxmMj0xOwoKICAgICAgICB3aGlsZSAoZjIrZjE8PU4pewogICAgICAgICAgICBsPS0xOwogICAgICAgICAgICBmb3IgKGk9MTsgaSppPD1OL2YyIHx8IChOLWYyKmkpLyhmMSppKT09bDsgaSsrKSBsPShOLWYyKmkpLyhmMSppKSxyZXMrPWw7CiAgICAgICAgICAgIGZvciAoaT0xOyBpPGw7IGkrKykgcmVzKz1pKihOLyhpKmYxK2YyKS1OLygoaSsxKSpmMStmMikpOwoKICAgICAgICAgICAgYXV4PWYxK2YyOwogICAgICAgICAgICBmMT1mMixmMj1hdXg7CiAgICAgICAgfQoKICAgICAgICBmb3IgKGk9MTsgaSppPD1OIHx8IGw9PU4vaTsgaSsrKSByZXMrPU4vaSxsPU4vaTsKICAgICAgICBmb3IgKGk9MTsgaTxsOyBpKyspIHJlcys9aSooTi9pLU4vKGkrMSkpOwogICAgICAgIGNvdXQgPDwgcmVzIDw8ICJcbiI7CiAgICB9Cn0=