#include<cstdio>
bool arr[2000001];
int main()
{
arr[0]=arr[1]=1;
for(int i=4;i<2000001;i+=2)
arr[i]=1;
for(int i=3;i*i<2000001;i+=2)
{
if(!arr[i])
for(int j=2;i*j<2000001;j++)
{
arr[i*j]=1;
}
}
int n,t;
scanf("%d",&t);
while(t--)
{
long long sum=0;
scanf("%d",&n);
for(int i=0;i<=n;i++)
{
if(!arr[i])
{
//printf("%d\n",i);
sum+=i;
}
}
printf("%lld\n",sum);
}
return 0;
}
I2luY2x1ZGU8Y3N0ZGlvPgpib29sIGFyclsyMDAwMDAxXTsKaW50IG1haW4oKQp7CiAgICBhcnJbMF09YXJyWzFdPTE7CiAgICBmb3IoaW50IGk9NDtpPDIwMDAwMDE7aSs9MikKICAgICAgICBhcnJbaV09MTsKICAgIGZvcihpbnQgaT0zO2kqaTwyMDAwMDAxO2krPTIpCiAgICB7CiAgICAgICAgaWYoIWFycltpXSkKICAgICAgICAgICAgZm9yKGludCBqPTI7aSpqPDIwMDAwMDE7aisrKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBhcnJbaSpqXT0xOwogICAgICAgICAgICB9CiAgICB9CiAgICBpbnQgbix0OwogICAgc2NhbmYoIiVkIiwmdCk7CiAgICB3aGlsZSh0LS0pCiAgICB7CiAgICAgICAgbG9uZyBsb25nIHN1bT0wOwogICAgICAgIHNjYW5mKCIlZCIsJm4pOwogICAgICAgIGZvcihpbnQgaT0wO2k8PW47aSsrKQogICAgICAgIHsKICAgICAgICAgICAgaWYoIWFycltpXSkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgLy9wcmludGYoIiVkXG4iLGkpOwogICAgICAgICAgICAgICAgc3VtKz1pOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHByaW50ZigiJWxsZFxuIixzdW0pOwogICAgfQogICAgcmV0dXJuIDA7Cn0=