#include
#include
#define ll long long
using namespace std;
ll sumOPrime(ll n, vector &isPrime){
ll sum=0;
for(ll i=0; i<=n; i++ )
if(isPrime[i])
sum+=i;
return sum;
}
int main() {
int testCases, n;
vector isPrime(100000,true);
isPrime[0]=false;
isPrime[1]=false;
for(ll i=0; i<=100000; i++)
if(isPrime[i])
for(ll j=i*2; j<=100000; j+=i)
isPrime[j]=false;
cin>>testCases;
while(testCases!=0){
scanf("%d", &n);
cout<<sumOPrime(n,isPrime)<<endl;
testCases–;
}
return 0;
}Preformatted text