#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 *, long long);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int T;
  scanf("%d", &T);
  long long n;
  for (int i_T = 0; i_T < T; i_T++) {
    scanf("%lld", &n);
    long long count_3 = (n - 1) / 3;
    long long count_5 = (n - 1) / 5;
    long long count_15 = (n - 1) / 15;
    long long sum = (3 * count_3 * (count_3 + 1) + 5 * count_5 * (count_5 + 1) -
                     15 * count_15 * (count_15 + 1)) >>
                    1;
    printf("%lld\n", sum);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1207 <main+0xe7>
lea    0xea8(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x10(%rbp),%rax
sub    $0x1,%rax
mov    $0x3,%ecx
cqto
idiv   %rcx
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
sub    $0x1,%rax
mov    $0x5,%ecx
cqto
idiv   %rcx
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
sub    $0x1,%rax
mov    $0xf,%ecx
cqto
idiv   %rcx
mov    %rax,-0x30(%rbp)
imul   $0x3,-0x20(%rbp),%rax
mov    -0x20(%rbp),%rcx
add    $0x1,%rcx
imul   %rcx,%rax
imul   $0x5,-0x28(%rbp),%rcx
mov    -0x28(%rbp),%rdx
add    $0x1,%rdx
imul   %rdx,%rcx
add    %rcx,%rax
imul   $0xf,-0x30(%rbp),%rcx
mov    -0x30(%rbp),%rdx
add    $0x1,%rdx
imul   %rdx,%rcx
sub    %rcx,%rax
sar    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rsi
lea    0xe14(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1148 <main+0x28>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xecb(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    122f <main+0x10f>
movabs $0x6666666666666667,%r13
66 66 66
movabs $0x8888888888888889,%r15
88 88 88
lea    0xea1(%rip),%r12
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
lea    0xe8c(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x10(%rsp),%r9
lea    -0x1(%r9),%rcx
mov    %rcx,%rax
movabs $0x5555555555555556,%rdx
55 55 55
imul   %rdx
mov    %rdx,%rbx
mov    %rdx,%rsi
shr    $0x3f,%rsi
lea    (%rdx,%rsi,1),%r8
mov    %rcx,%rax
imul   %r13
mov    %rdx,%rdi
mov    %rdx,%rbp
shr    $0x3f,%rbp
sar    %rdi
lea    (%rdi,%rbp,1),%r10
mov    %rcx,%rax
imul   %r15
lea    (%rdx,%r9,1),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x3,%rax
add    %rcx,%rax
lea    (%rbx,%rsi,1),%rcx
add    $0x1,%rcx
imul   %r8,%rcx
lea    (%rcx,%rcx,2),%rcx
lea    (%rdi,%rbp,1),%rdx
add    $0x1,%rdx
imul   %r10,%rdx
lea    (%rdx,%rdx,4),%rdx
add    %rcx,%rdx
mov    %rax,%rcx
not    %rcx
imul   %rax,%rcx
lea    (%rcx,%rcx,4),%rax
lea    (%rax,%rax,2),%rsi
add    %rdx,%rsi
sar    %rsi
mov    %r12,%rdi
call   1030 <printf@plt>
add    $0x1,%r14d
cmp    0xc(%rsp),%r14d
jl     1170 <main+0x50>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [5 x i8] c"%lld\00"
@.str.2 = [6 x i8] c"%lld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = bitcast i32* %1 to i8*
%4 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%5 = bitcast i64* %2 to i8*
%6 = load i32, i32* %1
%7 = icmp sgt i32 %6, 0
br i1 %7, label %9, label %8
8: ; preds = %9, %0
ret i32 0
9: ; preds = %0, %9
%10 = phi i32 [ %30, %9 ], [ 0, %0 ]
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64* %2)
%12 = load i64, i64* %2
%13 = add nsw i64 %12, -1
%14 = sdiv i64 %13, 3
%15 = sdiv i64 %13, 5
%16 = sdiv i64 %13, 15
%17 = mul nsw i64 %14, 3
%18 = add nsw i64 %14, 1
%19 = mul nsw i64 %17, %18
%20 = mul nsw i64 %15, 5
%21 = add nsw i64 %15, 1
%22 = mul nsw i64 %20, %21
%23 = add nsw i64 %19, %22
%24 = mul nsw i64 %16, 15
%25 = xor i64 %16, -1
%26 = mul i64 %24, %25
%27 = add i64 %23, %26
%28 = ashr i64 %27, 1
%29 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 %28)
%30 = add nuw nsw i32 %10, 1
%31 = load i32, i32* %1
%32 = icmp slt i32 %30, %31
br i1 %32, label %9, label %8
}