#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 days(long long *, int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  long long s[100001];
  int t = 0, n = 0, a = 0;
  scanf("%d", &t);
  for (int i = 0; i < t; ++i) {
    scanf("%d", &n);
    s[0] = 0;
    for (int j = 1; j <= n; ++j) {
      scanf("%d", &a);
      s[j] = s[j - 1] + a;
    }
    printf("%d\n", days(s, n));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc3530,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc3514(%rbp)
movl   $0x0,-0xc3518(%rbp)
movl   $0x0,-0xc351c(%rbp)
lea    0xe99(%rip),%rdi
lea    -0xc3514(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x0,-0xc3520(%rbp)
mov    -0xc3520(%rbp),%eax
cmp    -0xc3514(%rbp),%eax
jge    1250 <main+0x120>
lea    0xe6a(%rip),%rdi
lea    -0xc3518(%rbp),%rsi
call   1050 <scanf@plt>
movq   $0x0,-0xc3510(%rbp)
movl   $0x1,-0xc3524(%rbp)
mov    -0xc3524(%rbp),%eax
cmp    -0xc3518(%rbp),%eax
jg     121c <main+0xec>
lea    0xe30(%rip),%rdi
lea    -0xc351c(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0xc3524(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0xc3510(%rbp,%rax,8),%rcx
ff
movslq -0xc351c(%rbp),%rax
add    %rax,%rcx
movslq -0xc3524(%rbp),%rax
mov    %rcx,-0xc3510(%rbp,%rax,8)
ff
mov    -0xc3524(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc3524(%rbp)
jmp    11b7 <main+0x87>
lea    -0xc3510(%rbp),%rdi
mov    -0xc3518(%rbp),%esi
call   1030 <days@plt>
mov    %eax,%esi
lea    0xdcc(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc3520(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc3520(%rbp)
jmp    117d <main+0x4d>
xor    %eax,%eax
add    $0xc3530,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc3518,%rsp
movl   $0x0,0x8(%rsp)
movl   $0x0,0x4(%rsp)
movl   $0x0,0xc(%rsp)
lea    0xea0(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,0x8(%rsp)
jle    120a <main+0xda>
xor    %ebp,%ebp
lea    0xe82(%rip),%rbx
lea    0x10(%rsp),%r15
lea    0xe79(%rip),%r12
lea    0xc(%rsp),%r13
jmp    11bb <main+0x8b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1030 <days@plt>
mov    %r12,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    0x8(%rsp),%ebp
jge    120a <main+0xda>
mov    %rbx,%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
movq   $0x0,0x10(%rsp)
mov    0x4(%rsp),%esi
test   %esi,%esi
jle    11a0 <main+0x70>
xor    %r14d,%r14d
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r13,%rsi
call   1050 <scanf@plt>
movslq 0xc(%rsp),%rax
add    0x10(%rsp,%r14,8),%rax
mov    %rax,0x18(%rsp,%r14,8)
movslq 0x4(%rsp),%rsi
add    $0x1,%r14
cmp    %rsi,%r14
jl     11e0 <main+0xb0>
jmp    11a0 <main+0x70>
xor    %eax,%eax
add    $0xc3518,%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 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100001 x i64]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
store i32 0, i32* %6
br label %9
9: ; preds = %41, %0
%10 = load i32, i32* %6
%11 = load i32, i32* %3
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %44
13: ; preds = %9
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%15 = getelementptr inbounds [100001 x i64], [100001 x i64]* %2, i64 0, i64 0
store i64 0, i64* %15
store i32 1, i32* %7
br label %16
16: ; preds = %33, %13
%17 = load i32, i32* %7
%18 = load i32, i32* %4
%19 = icmp sle i32 %17, %18
br i1 %19, label %20, label %36
20: ; preds = %16
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%22 = load i32, i32* %7
%23 = sub nsw i32 %22, 1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [100001 x i64], [100001 x i64]* %2, i64 0, i64 %24
%26 = load i64, i64* %25
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = add nsw i64 %26, %28
%30 = load i32, i32* %7
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [100001 x i64], [100001 x i64]* %2, i64 0, i64 %31
store i64 %29, i64* %32
br label %33
33: ; preds = %20
%34 = load i32, i32* %7
%35 = add nsw i32 %34, 1
store i32 %35, i32* %7
br label %16
36: ; preds = %16
%37 = getelementptr inbounds [100001 x i64], [100001 x i64]* %2, i64 0, i64 0
%38 = load i32, i32* %4
%39 = call i32 @days(i64* %37, i32 %38)
%40 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %39)
br label %41
41: ; preds = %36
%42 = load i32, i32* %6
%43 = add nsw i32 %42, 1
store i32 %43, i32* %6
br label %9
44: ; preds = %9
ret i32 0
}

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