#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 *, long long *);
int main() {
  long long test, num, i, j, k;
  scanf("%lld", &test);
  while (test--) {
    scanf("%lld", &num);
    i = num * (num + 1);
    i = i % 1000007;
    j = ((num - 1) * (num)) / 2;
    j = j % 1000007;
    printf("%lld\n", (i + j) % 1000007);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x10(%rbp)
cmp    $0x0,%rax
je     11e1 <main+0xc1>
lea    0xea1(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x18(%rbp),%rax
mov    -0x18(%rbp),%rcx
add    $0x1,%rcx
imul   %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    $0xf4247,%ecx
cqto
idiv   %rcx
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rax
sub    $0x1,%rax
imul   -0x18(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    $0xf4247,%ecx
cqto
idiv   %rcx
mov    %rdx,-0x28(%rbp)
mov    -0x20(%rbp),%rax
add    -0x28(%rbp),%rax
mov    $0xf4247,%ecx
cqto
idiv   %rcx
mov    %rdx,%rsi
lea    0xe2e(%rip),%rdi
call   1030 <printf@plt>
jmp    113f <main+0x1f>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xece(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1040 <scanf@plt>
subq   $0x1,0x8(%rsp)
jb     1218 <main+0xf8>
lea    0xeb1(%rip),%r14
lea    0x10(%rsp),%r15
movabs $0x86377f7332675bb7,%rbx
7f 37 86
lea    0xea0(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    0x10(%rsp),%rsi
lea    0x1(%rsi),%rcx
imul   %rsi,%rcx
mov    %rcx,%rax
imul   %rbx
add    %rcx,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x13,%rdx
add    %rax,%rdx
imul   $0xf4247,%rdx,%rdi
lea    -0x1(%rsi),%rax
imul   %rsi,%rax
mov    %rax,%rsi
shr    $0x3f,%rsi
add    %rax,%rsi
sar    %rsi
mov    %rsi,%rax
imul   %rbx
sub    %rdi,%rcx
add    %rsi,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x13,%rdx
add    %rax,%rdx
imul   $0xf4247,%rdx,%rax
sub    %rax,%rsi
add    %rcx,%rsi
movslq %esi,%rax
imul   $0x218ddfdd,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x31,%rcx
add    %edx,%ecx
imul   $0xf4247,%ecx,%ecx
sub    %ecx,%eax
movslq %eax,%rsi
mov    %r12,%rdi
call   1030 <printf@plt>
subq   $0x1,0x8(%rsp)
jae    1170 <main+0x50>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"%lld\00"
@.str.1 = [6 x i8] c"%lld\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 ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %1)
%6 = load i64, i64* %1
%7 = add nsw i64 %6, -1
store i64 %7, i64* %1
%8 = icmp eq i64 %6, 0
br i1 %8, label %27, label %9
9: ; preds = %0, %9
%10 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %2)
%11 = load i64, i64* %2
%12 = add nsw i64 %11, 1
%13 = mul nsw i64 %12, %11
%14 = srem i64 %13, 1000007
%15 = add nsw i64 %11, -1
%16 = mul nsw i64 %15, %11
%17 = sdiv i64 %16, 2
%18 = srem i64 %17, 1000007
%19 = add nsw i64 %18, %14
%20 = trunc i64 %19 to i32
%21 = srem i32 %20, 1000007
%22 = sext i32 %21 to i64
%23 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 %22)
%24 = load i64, i64* %1
%25 = add nsw i64 %24, -1
store i64 %25, i64* %1
%26 = icmp eq i64 %24, 0
br i1 %26, label %27, label %9
27: ; preds = %9, %0
ret i32 0
}