#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, unsigned long long);
int /*<<< orphan*/ scanf(char *, unsigned long long *);
int main() {
  unsigned long long N, T;
  scanf("%Lu", &T);
  while (T--) {
    unsigned long long i, j;
    unsigned long long total = 2;
    int flag = 0;
    scanf("%Lu", &N);
    for (i = 3; i <= N; i++) {
      flag = 0;
      for (j = 2; j <= i / 2; j++) {
        if (i % j == 0) {
          flag = 1;
          break;
        }
      }
      if (flag == 0) {
        total += i;
      }
    }
    if (N != 0 || N != 1) {
      printf("%Lu\n", total);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x18(%rbp)
cmp    $0x0,%rax
je     1240 <main+0x120>
movq   $0x2,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
lea    0xe92(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
movq   $0x3,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
ja     1215 <main+0xf5>
movl   $0x0,-0x34(%rbp)
movq   $0x2,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
shr    $0x1,%rcx
cmp    %rcx,%rax
ja     11e9 <main+0xc9>
mov    -0x20(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x28(%rbp)
cmp    $0x0,%rdx
jne    11d3 <main+0xb3>
movl   $0x1,-0x34(%rbp)
jmp    11e9 <main+0xc9>
jmp    11d8 <main+0xb8>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    119c <main+0x7c>
cmpl   $0x0,-0x34(%rbp)
jne    11ff <main+0xdf>
mov    -0x20(%rbp),%rax
add    -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    1204 <main+0xe4>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    117f <main+0x5f>
cmpq   $0x0,-0x10(%rbp)
jne    122b <main+0x10b>
cmpq   $0x1,-0x10(%rbp)
je     123b <main+0x11b>
mov    -0x30(%rbp),%rsi
lea    0xdce(%rip),%rdi
call   1030 <printf@plt>
jmp    113f <main+0x1f>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xecc(%rip),%rdi
mov    %rsp,%rsi
call   1040 <scanf@plt>
subq   $0x1,(%rsp)
jae    1153 <main+0x33>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xea6(%rip),%r14
lea    0x8(%rsp),%r15
lea    0xe9e(%rip),%r12
mov    $0x2,%r13d
jmp    117f <main+0x5f>
xchg   %ax,%ax
mov    %r12,%rdi
call   1030 <printf@plt>
subq   $0x1,(%rsp)
jb     1143 <main+0x23>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    0x8(%rsp),%r8
mov    $0x2,%esi
cmp    $0x3,%r8
jb     1170 <main+0x50>
mov    $0x3,%ecx
mov    $0x2,%esi
jmp    11c1 <main+0xa1>
cs nopw 0x0(%rax,%rax,1)
xor    %edx,%edx
add    %rdx,%rsi
lea    0x1(%rcx),%rax
cmp    %r8,%rcx
mov    %rax,%rcx
je     1170 <main+0x50>
mov    %rcx,%rax
shr    %rax
cmp    $0x3,%rax
cmovb  %r13,%rax
mov    %rcx,%rdx
cmp    $0x4,%rcx
jb     11b2 <main+0x92>
mov    $0x1,%ebx
sub    %rax,%rbx
mov    $0x2,%edi
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rcx,%rax
or     %rdi,%rax
shr    $0x20,%rax
je     1210 <main+0xf0>
mov    %rcx,%rax
xor    %edx,%edx
div    %rdi
test   %rdx,%rdx
jne    121b <main+0xfb>
jmp    11b0 <main+0x90>
nopl   0x0(%rax,%rax,1)
mov    %ecx,%eax
xor    %edx,%edx
div    %edi
test   %rdx,%rdx
je     11b0 <main+0x90>
lea    (%rbx,%rdi,1),%rax
add    $0x1,%rax
add    $0x1,%rdi
cmp    $0x2,%rax
jne    11f0 <main+0xd0>
mov    %rcx,%rdx
jmp    11b2 <main+0x92>

LLVM IR (-O0):
@.str = [4 x i8] c"%Lu\00"
@.str.1 = [5 x i8] c"%Lu\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %3)
br label %9
9: ; preds = %55, %0
%10 = load i64, i64* %3
%11 = add i64 %10, -1
store i64 %11, i64* %3
%12 = icmp ne i64 %10, 0
br i1 %12, label %13, label %56
13: ; preds = %9
store i64 2, i64* %6
store i32 0, i32* %7
%14 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %2)
store i64 3, i64* %4
br label %15
15: ; preds = %43, %13
%16 = load i64, i64* %4
%17 = load i64, i64* %2
%18 = icmp ule i64 %16, %17
br i1 %18, label %19, label %46
19: ; preds = %15
store i32 0, i32* %7
store i64 2, i64* %5
br label %20
20: ; preds = %32, %19
%21 = load i64, i64* %5
%22 = load i64, i64* %4
%23 = udiv i64 %22, 2
%24 = icmp ule i64 %21, %23
br i1 %24, label %25, label %35
25: ; preds = %20
%26 = load i64, i64* %4
%27 = load i64, i64* %5
%28 = urem i64 %26, %27
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %25
store i32 1, i32* %7
br label %35
31: ; preds = %25
br label %32
32: ; preds = %31
%33 = load i64, i64* %5
%34 = add i64 %33, 1
store i64 %34, i64* %5
br label %20
35: ; preds = %30, %20
%36 = load i32, i32* %7
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %42
38: ; preds = %35
%39 = load i64, i64* %4
%40 = load i64, i64* %6
%41 = add i64 %40, %39
store i64 %41, i64* %6
br label %42
42: ; preds = %38, %35
br label %43
43: ; preds = %42
%44 = load i64, i64* %4
%45 = add i64 %44, 1
store i64 %45, i64* %4
br label %15
46: ; preds = %15
%47 = load i64, i64* %2
%48 = icmp ne i64 %47, 0
br i1 %48, label %52, label %49
49: ; preds = %46
%50 = load i64, i64* %2
%51 = icmp ne i64 %50, 1
br i1 %51, label %52, label %55
52: ; preds = %49, %46
%53 = load i64, i64* %6
%54 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %53)
br label %55
55: ; preds = %52, %49
br label %9
56: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%Lu\00"
@.str.1 = [5 x i8] c"%Lu\0A\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca i64
%3 = bitcast i64* %1 to i8*
%4 = bitcast i64* %2 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %2)
%6 = load i64, i64* %2
%7 = add i64 %6, -1
store i64 %7, i64* %2
%8 = icmp eq i64 %6, 0
br i1 %8, label %37, label %9
9: ; preds = %0, %31
%10 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %1)
%11 = load i64, i64* %1
%12 = icmp ult i64 %11, 3
br i1 %12, label %31, label %13
13: ; preds = %9, %26
%14 = phi i64 [ %28, %26 ], [ 2, %9 ]
%15 = phi i64 [ %29, %26 ], [ 3, %9 ]
%16 = lshr i64 %15, 1
%17 = call i64 @llvm.umax.i64(i64 %16, i64 2)
%18 = icmp ult i64 %15, 4
br i1 %18, label %26, label %22
19: ; preds = %22
%20 = add nuw i64 %23, 1
%21 = icmp eq i64 %23, %17
br i1 %21, label %26, label %22
22: ; preds = %13, %19
%23 = phi i64 [ %20, %19 ], [ 2, %13 ]
%24 = urem i64 %15, %23
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %19
26: ; preds = %19, %22, %13
%27 = phi i64 [ %15, %13 ], [ 0, %22 ], [ %15, %19 ]
%28 = add i64 %27, %14
%29 = add nuw i64 %15, 1
%30 = icmp eq i64 %15, %11
br i1 %30, label %31, label %13
31: ; preds = %26, %9
%32 = phi i64 [ 2, %9 ], [ %28, %26 ]
%33 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %32)
%34 = load i64, i64* %2
%35 = add i64 %34, -1
store i64 %35, i64* %2
%36 = icmp eq i64 %34, 0
br i1 %36, label %37, label %9
37: ; preds = %31, %0
ret i32 0
}