#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 */
long long *malloc(int);
int /*<<< orphan*/ printf(char *, long long);
int /*<<< orphan*/ scanf(char *, long *);
int main() {
  long long *result = malloc(sizeof(long) * 1000001);
  result[0] = 1;
  for (long i = 1; i < 1000002; ++i)
    result[i] = result[i - 1] * (i + 1) % 1000000007;
  long t, n;
  scanf("%ld", &t);
  while (t--) {
    scanf("%ld", &n);
    printf("%ld\n", (result[n] - 1) % 1000000007);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x7a1208,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movq   $0x1,(%rax)
movq   $0x1,-0x18(%rbp)
cmpq   $0xf4242,-0x18(%rbp)
jge    11b1 <main+0x81>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    $0x1,%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x18(%rbp),%rcx
add    $0x1,%rcx
imul   %rcx,%rax
mov    $0x3b9aca07,%ecx
cqto
idiv   %rcx
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1160 <main+0x30>
lea    0xe48(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x20(%rbp)
cmp    $0x0,%rax
je     1218 <main+0xe8>
lea    0xe1f(%rip),%rdi
lea    -0x28(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
sub    $0x1,%rax
mov    $0x3b9aca07,%ecx
cqto
idiv   %rcx
mov    %rdx,%rsi
lea    0xdf6(%rip),%rdi
call   1030 <printf@plt>
jmp    11c1 <main+0x91>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    $0x7a1208,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
movq   $0x1,(%rax)
mov    $0x1,%eax
mov    $0x3,%esi
movabs $0x89705f3112a28fe5,%r13
5f 70 89
cs nopw 0x0(%rax,%rax,1)
nop
lea    -0x1(%rsi),%rcx
imul   %rax,%rcx
mov    %rcx,%rax
imul   %r13
add    %rcx,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x1d,%rdx
add    %rax,%rdx
imul   $0x3b9aca07,%rdx,%rax
sub    %rax,%rcx
mov    %rcx,-0x10(%rbx,%rsi,8)
cmp    $0xf4243,%rsi
je     11da <main+0xaa>
imul   %rsi,%rcx
mov    %rcx,%rax
imul   %r13
add    %rcx,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x1d,%rdx
add    %rax,%rdx
imul   $0x3b9aca07,%rdx,%rax
sub    %rax,%rcx
mov    %rcx,-0x8(%rbx,%rsi,8)
add    $0x2,%rsi
mov    %rcx,%rax
jmp    1170 <main+0x40>
lea    0xe1f(%rip),%rdi
mov    %rsp,%rsi
call   1050 <scanf@plt>
subq   $0x1,(%rsp)
jb     1262 <main+0x132>
lea    0xe09(%rip),%r14
lea    0x8(%rsp),%r15
lea    0xe01(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
mov    0x8(%rsp),%rax
mov    (%rbx,%rax,8),%rcx
lea    -0x1(%rcx),%rax
imul   %r13
lea    (%rdx,%rcx,1),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x1d,%rax
add    %rdx,%rax
imul   $0x3b9aca07,%rax,%rax
neg    %rax
lea    (%rcx,%rax,1),%rsi
add    $0xffffffffffffffff,%rsi
mov    %r12,%rdi
call   1030 <printf@plt>
subq   $0x1,(%rsp)
jae    1210 <main+0xe0>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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