using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class Solution {
static void Main(String[] args) {
int t = Convert.ToInt32(Console.ReadLine());
for(int a0 = 0; a0 < t; a0++){
int n = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(PrimeSum(n));
}
}
static long PrimeSum(int n)
{
long sum = 2;
if (n == 2) return 2;
for (var i = 3; i <= n; i+=2)
{
if (IsPrime(i))
{
sum += i;
}
}
return sum;
}
static bool IsPrime(int n)
{
if (n == 2 || n == 3)
return true;
if (n <= 1 || n % 2 == 0 || n % 3 == 0)
return false;
for (int i = 5; i * i <= n; i += 6)
{
if (n % i == 0 || n % (i + 2) == 0)
return false;
}
return true;
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uQ29sbGVjdGlvbnMuR2VuZXJpYzsKdXNpbmcgU3lzdGVtLklPOwp1c2luZyBTeXN0ZW0uTGlucTsKY2xhc3MgU29sdXRpb24gewoKICAgIHN0YXRpYyB2b2lkIE1haW4oU3RyaW5nW10gYXJncykgewogICAgICAgIGludCB0ID0gQ29udmVydC5Ub0ludDMyKENvbnNvbGUuUmVhZExpbmUoKSk7CiAgICAgICAgZm9yKGludCBhMCA9IDA7IGEwIDwgdDsgYTArKyl7CiAgICAgICAgICAgIGludCBuID0gQ29udmVydC5Ub0ludDMyKENvbnNvbGUuUmVhZExpbmUoKSk7CiAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKFByaW1lU3VtKG4pKTsKICAgICAgICB9CiAgICB9CiAgICBzdGF0aWMgbG9uZyBQcmltZVN1bShpbnQgbikKICAgICAgICB7CiAgICAgICAgICAgIGxvbmcgc3VtID0gMjsKICAgICAgICAgICAgaWYgKG4gPT0gMikgcmV0dXJuIDI7CgogICAgICAgICAgICBmb3IgKHZhciBpID0gMzsgaSA8PSBuOyBpKz0yKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBpZiAoSXNQcmltZShpKSkKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBzdW0gKz0gaTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm4gc3VtOwogICAgICAgIH0KICAgICAgICBzdGF0aWMgYm9vbCBJc1ByaW1lKGludCBuKQogICAgICAgIHsKICAgICAgICAgICAgaWYgKG4gPT0gMiB8fCBuID09IDMpCiAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKCiAgICAgICAgICAgIGlmIChuIDw9IDEgfHwgbiAlIDIgPT0gMCB8fCBuICUgMyA9PSAwKQogICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwoKICAgICAgICAgICAgZm9yIChpbnQgaSA9IDU7IGkgKiBpIDw9IG47IGkgKz0gNikKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgaWYgKG4gJSBpID09IDAgfHwgbiAlIChpICsgMikgPT0gMCkKICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgIH0KCiAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgIH0KfQ==