Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a=int(input())
if a==1:
    print("Hello World")
if a==2:
    b,c = map(int, input().split())
    print(b+c)

Fixed submission:
a=int(input())
if a==1:
    print("Hello World")
if a==2:
    b=int(input())
    c=int(input())
    print(b+c)
Buggy python submission (verdict: Runtime Error):
total_subjects, max_points, target_points = map(int, input().split())
subject_points = list(map(int, input().split()))

calc_result = (total_subjects * target_points) - sum(subject_points)

if calc_result > max_points:
    print(-1)
elif calc_result < 0:
    print(0)
else:
    print(calc_result)


Fixed submission:
small_alpha = str(input())
alpha_list = [chr(ord('a') + i) for i in range(26)]
for num, alpha in enumerate(alpha_list):
    if alpha == small_alpha:
        print(alpha_list[num + 1])

Buggy python submission (verdict: Runtime Error):
total_subjects, max_points, target_points = map(int, input().split())
subject_points = list(map(int, input().split()))

calc_result = total_subjects * target_points - sum(subject_points)

if calc_result > max_points:
    print(-1)
elif calc_result < 0:
    print(0)
else:
    print(calc_result)

Fixed submission:
small_alpha = str(input())
alpha_list = [chr(ord('a') + i) for i in range(26)]
for num, alpha in enumerate(alpha_list):
    if alpha == small_alpha:
        print(alpha_list[num + 1])

Buggy python submission (verdict: Runtime Error):
total_subjects, max_points, target_points = map(int, input().split())
subject_points = input().split()
total_points = 0

for subject_point in subject_points:
    total_points += int(subject_point)

calc_result = total_subjects * target_points - total_points

if calc_result > max_points:
    print(-1)
elif calc_result < 0:
    print(0)
else:
    print(calc_result)

Fixed submission:
small_alpha = str(input())
alpha_list = [chr(ord('a') + i) for i in range(26)]
for num, alpha in enumerate(alpha_list):
    if alpha == small_alpha:
        print(alpha_list[num + 1])
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(input().split())
a.sort(reverse=True)
print(sum(a[0::2]) - sum(a[1::2]))

Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]
a.sort(reverse=True)
print(sum(a[0::2]) - sum(a[1::2]))
Buggy python submission (verdict: Runtime Error):
n, y = map(int, input().split())
for i in range(n + 1):
    for j in range(n - i + 1):
        if i * 10000 + j * 5000 + (n - i - j) * 1000 == y:
            print("{0} {1} {2}".format(i, j, (n - i - j)))
            exit(0)

Fixed submission:
n = int(input())
print(len(set(map(int, [input() for _ in range(n)]))))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = []
counter = 0
a = input().split()
success_result = [0] * n
while True:
    for index, item in enumerate(a):
        if int(item) % 2 == 0:
            a[index] = int(item) / 2
            success_result[index] = True
        else:
            continue
    if all(success_result):
        counter += 1
        success_result = [None for _ in range(n)]
    else:
        break
print(counter)

Fixed submission:
print(input().count("1"))

Buggy python submission (verdict: Runtime Error):
    n = int(input())
    a = []
    count = 0
    for i in range(n):
        a.append(input())
    while True:
        for index, item in enumerate(a):
            if item % 2 == 0:
                a[index] = item / 2
                count += 1
            else:
                break
    print(count)

Fixed submission:
print(input().count("1"))
Buggy python submission (verdict: Runtime Error):
n=int(input())
m=int(input())
rate=2*n*m/((n+m)*(n+m-1))
print(int((n+m)*rate))

Fixed submission:
n,m=(input().split())
n=int(n)
m=int(m)
print(int(((n*(n-1))+(m*(m-1)))/2))
Buggy python submission (verdict: Runtime Error):
r = input()
print(r ** 2)


Fixed submission:
r = int(input())
print(r**2)
Buggy python submission (verdict: Time Limit Exceeded):
import math as m

a, b, x = map(int, input().split())

x = float(x)
d_max = float(90)
d_min = float(0)
res = float(100)

if x >= a**2*b:
    print(0)
    exit()

if x < a*a*b/100:
    d_max = float(1)

while res > 10e-8:
    d_mid = (d_max+d_min)/2
    l1 = a*m.tan(d_mid/180*m.pi)
    if l1-b > 0:
        l2 = (l1-b)*m.tan((90-d_mid)/180*m.pi)
    else:
        l2 = 0
    v = a*(a*b - 1/2*a*l1 + 1/2*(l1-b)*l2)
    res = abs(x-v)
    if x - v < 0:
        d_min = d_mid
    else:
        d_max = d_mid
print(d_mid)

Fixed submission:
import math as m

def vol(a,b,x,d):
    if a**2*b / 2 < x:
        return a**2*b - 1/2*a**3 * m.tan(m.radians(d))
    else:
        return 1/2*a*b**2 * m.tan(m.radians(90-d))

a, b, x = map(int, input().split())

if a**2*b == x:
    print(0)
    exit()

res = x
d_max = 90
d_min = 0
while res > 10e-8:
    d = (d_max+d_min)/2
    if vol(a,b,x,d) - x > 0:
        d_min = d
    else:
        d_max = d
    res = abs(x - vol(a,b,x,d))

print(d)

Buggy python submission (verdict: Time Limit Exceeded):
import math as m

a, b, x = map(int, input().split())

x = float(x)
d_max = float(90)
d_min = float(0)
res = float(100)

if x >= a**2*b:
    print(0)
    exit()

while res > 10e-8:
    d_mid = (d_max+d_min)/2
    l1 = a*m.tan(d_mid/180*m.pi)
    if l1-b > 0:
        l2 = (l1-b)*m.tan((90-d_mid)/180*m.pi)
    else:
        l2 = 0
    v = a*(a*b - 1/2*a*l1 + 1/2*(l1-b)*l2)
    res = abs(x-v)
    if x - v < 0:
        d_min = d_mid
    else:
        d_max = d_mid
print(d_mid)

Fixed submission:
import math as m

def vol(a,b,x,d):
    if a**2*b / 2 < x:
        return a**2*b - 1/2*a**3 * m.tan(m.radians(d))
    else:
        return 1/2*a*b**2 * m.tan(m.radians(90-d))

a, b, x = map(int, input().split())

if a**2*b == x:
    print(0)
    exit()

res = x
d_max = 90
d_min = 0
while res > 10e-8:
    d = (d_max+d_min)/2
    if vol(a,b,x,d) - x > 0:
        d_min = d
    else:
        d_max = d
    res = abs(x - vol(a,b,x,d))

print(d)

Buggy python submission (verdict: Time Limit Exceeded):
import math as m

a, b, x = map(int, input().split())

x = float(x)
d_max = float(90)
d_min = float(0)
res = float(100)

if x == a**2*b:
    print(0)
    exit()

while res > 10e-8:
    d_mid = (d_max+d_min)/2
    l1 = a*m.tan(d_mid/180*m.pi)
    if l1-b > 0:
        l2 = (l1-b)*m.tan((90-d_mid)/180*m.pi)
    else:
        l2 = 0
    v = a*(a*b - 1/2*a*l1 + 1/2*(l1-b)*l2)
    res = abs(x-v)
    if x - v < 0:
        d_min = d_mid
    else:
        d_max = d_mid
print(d_mid)

Fixed submission:
import math as m

def vol(a,b,x,d):
    if a**2*b / 2 < x:
        return a**2*b - 1/2*a**3 * m.tan(m.radians(d))
    else:
        return 1/2*a*b**2 * m.tan(m.radians(90-d))

a, b, x = map(int, input().split())

if a**2*b == x:
    print(0)
    exit()

res = x
d_max = 90
d_min = 0
while res > 10e-8:
    d = (d_max+d_min)/2
    if vol(a,b,x,d) - x > 0:
        d_min = d
    else:
        d_max = d
    res = abs(x - vol(a,b,x,d))

print(d)
Buggy python submission (verdict: Time Limit Exceeded):
from math import ceil

n = int(input())
l = list(map(int, input().split()))
l.sort()
# print(l)
ans = 0
for i in range(len(l)):
    for left in range(i+1, len(l)):
        right = left
        while right+1 < len(l) and l[right+1] < l[left] + l[i]:
            right += 1
        ans += right - left

print(ans)

Fixed submission:
n = int(input())
l = list(map(int, input().split()))
l.sort()

ans = 0
for i in range(len(l)):
    right = i+1
    for left in range(i+1, len(l)):
        while right+1 < len(l) and l[right+1] < l[left] + l[i]:
            right += 1
        ans += right - left
        if right == left:
            right += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int, input().split()))
l.sort()
# print(l)
ans = 0
for i in range(len(l)):
    for j in range(i+1, len(l)):
        k = j + 1
        if k == len(l):
            continue
        if l[i] + l[j] <= l[k]:
            continue
        while k + 1 < len(l) and l[i] + l[j] > l[k+1]:
            k += 1
        ans += k - j

print(ans)
        


Fixed submission:
n = int(input())
l = list(map(int, input().split()))
l.sort()

ans = 0
for i in range(len(l)):
    right = i+1
    for left in range(i+1, len(l)):
        while right+1 < len(l) and l[right+1] < l[left] + l[i]:
            right += 1
        ans += right - left
        if right == left:
            right += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations

n = int(input())
l = list(map(int, input().split()))
l.sort()
comb = list(combinations(l,3))

ans = 0
for c in comb:
    if c[0] + c[1] - c[2] > 0:
        ans += 1

print(ans)


Fixed submission:
n = int(input())
l = list(map(int, input().split()))
l.sort()

ans = 0
for i in range(len(l)):
    right = i+1
    for left in range(i+1, len(l)):
        while right+1 < len(l) and l[right+1] < l[left] + l[i]:
            right += 1
        ans += right - left
        if right == left:
            right += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations

n = int(input())
l = list(map(int, input().split()))
comb = list(combinations(l,3))

ans = 0
for c in comb:
    if sum(c) - 2*max(c) > 0:
        ans += 1

print(ans)

Fixed submission:
n = int(input())
l = list(map(int, input().split()))
l.sort()

ans = 0
for i in range(len(l)):
    right = i+1
    for left in range(i+1, len(l)):
        while right+1 < len(l) and l[right+1] < l[left] + l[i]:
            right += 1
        ans += right - left
        if right == left:
            right += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
od = []
for i in range(n):
    od.append(a.index(i+1)+1)
for i in range(n):
    if i != n-1:
        print(od[i], end=' ')
    else:
        print(od[i])

Fixed submission:
import heapq as hq

n = int(input())
a = list(map(int, input().split()))
b = [i for i in range(1, n+1)]
p = list(zip(a, b))

q = []
hq.heapify(q)
for i in range(len(p)):
    hq.heappush(q, p[i])

while len(q) != 0:
    print(q[0][1], end=' ')
    hq.heappop(q)
Buggy python submission (verdict: Runtime Error):
import math as m
import fractions as fr

def is_prime(n): #素数かどうか判定
    if n == 1: return False
    for k in range(2, int(m.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table   

a, b = map(int, input().split())
g = fr.gcd(a,b)
tb = divisor(g)

count = 1
for i in tb:
    if is_prime(i):
        count += 1

print(count)

def is_prime(n): #素数かどうか判定
    if n == 1: return False
    for k in range(2, int(m.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table   

a, b = map(int, input().split())
g = m.gcd(a,b)
tb = divisor(g)

count = 1
for i in tb:
    if is_prime(i):
        count += 1

print(count)

Fixed submission:
import math as m
import fractions as fr

def is_prime(n): #素数かどうか判定
    if n == 1: return False
    for k in range(2, int(m.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table   

a, b = map(int, input().split())
g = fr.gcd(a,b)
tb = divisor(g)

count = 1
for i in tb:
    if is_prime(i):
        count += 1

print(count)

Buggy python submission (verdict: Runtime Error):
import math as m

def is_prime(n): #素数かどうか判定
    if n == 1: return False
    for k in range(2, int(m.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table   

a, b = map(int, input().split())
g = m.gcd(a,b)

tb = divisor(g)

count = 1
for i in tb:
    if is_prime(i):
        count += 1

print(count)

Fixed submission:
import math as m
import fractions as fr

def is_prime(n): #素数かどうか判定
    if n == 1: return False
    for k in range(2, int(m.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table   

a, b = map(int, input().split())
g = fr.gcd(a,b)
tb = divisor(g)

count = 1
for i in tb:
    if is_prime(i):
        count += 1

print(count)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())

if b > 1:
    c = 1
    for i in range(1,21):
        c = c + (a - 1)
        if c >= b:
            print(i)
            break
else:
    print(0)

Fixed submission:
a, b = map(int, input().split())

if b > 1:
    c = 1
    for i in range(1,21):
        c = c + (a - 1)
        if c >= b:
            print(i)
            break
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())

if b > 1:
    c = 1
    for i in range(1,21):
        c = c + (a - 1)
        if c >= b:
            print(i)
            break
else:
    print(0)

Fixed submission:
a, b = map(int, input().split())

if b > 1:
    c = 1
    for i in range(1,21):
        c = c + (a - 1)
        if c >= b:
            print(i)
            break
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())

if b > 1:
    c = 1
    for i in range(1,21):
        c = c + (a - 1)
        if c >= b:
            print(i)
            break
else:
    print(0)

Fixed submission:
a, b = map(int, input().split())

if b > 1:
    c = 1
    for i in range(1,21):
        c = c + (a - 1)
        if c >= b:
            print(i)
            break
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(input()) for _ in range(n)]

for i in range(n):
    b = a[:i] + a[i+1:]
    print(max(b))

Fixed submission:
n = int(input())
a = [int(input()) for _ in range(n)]

max_v1 = max(a)
max_i1 = a.index(max_v1)
a.remove(max_v1)
max_v2 = max(a)

for i in range(n):
    if i == max_i1:
        print(max_v2)
    else:
        print(max_v1)
Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = list(map(int, input().split()))

cd = 0
for i in range(n):
    cd += l[i]
    if cd > x:
        ans = i + 1
        break

print(ans)

Fixed submission:
n, x = map(int, input().split())
l = list(map(int, input().split()))

cd = 0
ans = n + 1 # xに到達しない場合

for i in range(n):
    cd += l[i]
    if cd > x:
        ans = i + 1
        break

print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
w = list(map(int, input().split()))

res = sum(w)
sum1 = 0
sum2 = sum(w)
for i in range(n):
    sum1 += w[i]
    sum2 -= w[i]
    res = min(res, abs(sum2-sum1))

print(ans)

Fixed submission:
n = int(input())
w = list(map(int, input().split()))

res = sum(w)
sum1 = 0
sum2 = sum(w)
for i in range(n):
    sum1 += w[i]
    sum2 -= w[i]
    res = min(res, abs(sum2-sum1))

print(res)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations as c

n = int(input())
s = input()

ans = 0
for i in range(n): # i+1文字取り出す場合
    num = i+1
    l = list(c(s, num))
    for j in l:
        if len(j) == len(set(j)):
            ans += 1

print(ans)

Fixed submission:
from collections import Counter

n = int(input())
s = list(input())
c = Counter(s)
m = 10**9 + 7

ans = 1
for i in c:
    ans *= (c[i] + 1)
    ans %= m
ans -= 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
l_s = []
for i in range(len(s)):
    l_s.append(s[i])

b = True
if len(l_s) == 1:
    print(0)
    exit()

while len(l_s) > 0 and b == True:
    for i in range(len(l_s) - 1):
        if l_s[i] != l_s[i+1]:
            del l_s[i:i+2]
            break
        if i == len(l_s) - 2:
            b = False

ans = len(s) - len(l_s)
print(ans)

Fixed submission:
from collections import Counter
s = input()
c = Counter(s)
print(min(c['1'], c['0'])*2)
Buggy python submission (verdict: Runtime Error):
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))

res = 200
for i in range(len(h)):
    x = h[i]
    res_n = abs(a - (t - x * 0.006))
    # print(res_n)
    if res > res_n:
        res = res_n
        ans = i

print(ans + 1)

Fixed submission:
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))

res = abs(a - (t - h[0] * 0.006))
ans = 1
for i in range(len(h)):
    x = h[i]
    res_n = abs(a - (t - x * 0.006))
    # print(res_n)
    if res > res_n:
        res = res_n
        ans = i + 1

print(ans)
Buggy python submission (verdict: Runtime Error):
N, X = map(int, input().split())
x = list(map(int, input().split()))
x.append(X)
x.sort()
d = 10 ** 9

for i in range(N+1):
    d = min(d, x[i+1] - x[i])

print(d)

Fixed submission:
from fractions import gcd

N, X = map(int, input().split())
x = list(map(int, input().split()))

g = abs(max(x) - X)
for i in range(N):
    g = gcd(abs(x[i] - X), g)

print(g)
Buggy python submission (verdict: Runtime Error):
n = int(input())
// 3*5*7, 3*5*11, 3*5*13
if n < 3*5*7:
    print(0)
elif n < 3*5*11:
    print(1)
elif n < 3*5*13:
    print(2)
else:
    print(3)

Fixed submission:
def fact(n):
    num = n
    cnt = [0]*(n+1)
    ans = 1
    for i in range(2, n+1):
        while num % i == 0:
            cnt[i] += 1
            num /= i
    for i in range(2, n+1):
        ans *= cnt[i] + 1
    return ans

n = int(input())

res = 0
for i in range(1, n+1):
    if i % 2 == 1 and fact(i) == 8:
        res += 1
print(res)
Buggy python submission (verdict: Runtime Error):
s = input()
k = int(input())

if len(s) == 1:
    print(s[0])
    exit()

if k == 1:
    print(s[0])
else:
    i = 0
    while i <= k:
        if s[i] != '1':
            print(s[i])
            break
        elif i == k:
            print(s[i])
            break
        i += 1


Fixed submission:
s = input()
k = int(input())

if len(s) == 1:
    print(s[0])
    exit()

if k == 1:
    print(s[0])
else:
    i = 1
    while i <= k:
        if s[i-1] != '1':
            print(s[i-1])
            break
        elif i == k:
            print(s[i-1])
            break
        i += 1

Buggy python submission (verdict: Runtime Error):
s = input()
k = int(input())

if len(s) == 1:
    print(s[0])
    exit()

if k == 1:
    print(s[0])
else:
    i == 0
    while i <= k:
        if s[i] != '1':
            print(s[i])
            break
        elif i == k:
            print(s[i])
            break
        i += 1


Fixed submission:
s = input()
k = int(input())

if len(s) == 1:
    print(s[0])
    exit()

if k == 1:
    print(s[0])
else:
    i = 1
    while i <= k:
        if s[i-1] != '1':
            print(s[i-1])
            break
        elif i == k:
            print(s[i-1])
            break
        i += 1

Buggy python submission (verdict: Runtime Error):
s = input()
k = int(input())

if k == 1:
    print(s[0])
else:
    print(s[1])

Fixed submission:
s = input()
k = int(input())

if len(s) == 1:
    print(s[0])
    exit()

if k == 1:
    print(s[0])
else:
    i = 1
    while i <= k:
        if s[i-1] != '1':
            print(s[i-1])
            break
        elif i == k:
            print(s[i-1])
            break
        i += 1
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
i = 0
while True:
    ans = 0
    for j in range(len(str(bin(i)))-2):
        if i & 1 << j:
            ans += (-2)**j
    if ans == n:
        print(bin(i)[2:])
        break
    i += 1

Fixed submission:
def conv(s):
    s = list(s)
    s.reverse()
    ret = 0
    for i in range(len(s)):
        ret += int(s[i]) * (-2)**i
    return ret

n = int(input())
if n == 0:
    print(0)
    exit()

s = ''
d = 2
while abs(n) > 0:
    if n % d == 0:
        s = '0' + s
    else:
        s = '1' + s
    n -= conv(s[0]+'0'*(len(s)-1))
    d *= 2

print(s)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()

min_n = s[1:].count('E')
for i in range(1, n):
    tmp_n += s[i-1].count('W') - s[i].count('E')
    min_n = min(tmp_n, min_n)

print(min_n)

Fixed submission:
n = int(input())
s = input()

min_n = s[1:].count('E')
tmp_n = min_n
for i in range(1, n):
    tmp_n += s[i-1].count('W') - s[i].count('E')
    min_n = min(tmp_n, min_n)

print(min_n)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

min_n = n
for i in range(n):
    tmp_n = s[:i].count('W') + s[i+1:].count('E')
    min_n = min(tmp_n, min_n)

print(min_n)

Fixed submission:
n = int(input())
s = input()

min_n = s[1:].count('E')
tmp_n = min_n
for i in range(1, n):
    tmp_n += s[i-1].count('W') - s[i].count('E')
    min_n = min(tmp_n, min_n)

print(min_n)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split)
if a <= b:
    print(a)
else:
    print(a-1)

Fixed submission:
a, b = map(int, input().split())
if a <= b:
    print(a)
else:
    print(a-1)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

n = int(input())
a = list(map(int, input().split()))

l_sum = []
s= 0
for i in range(n):
    s += a[i]
    l_sum.append(s)

ans = 0
for i in range(n):
    if l_sum[i] == 0:
        ans += 1
    for j in range(i+1, n):
        if l_sum[i] == l_sum[j]:
            ans += 1

print(ans)

Fixed submission:
from collections import Counter

n = int(input())
a = list(map(int, input().split()))

l_sum = [0]
s= 0
for i in range(n):
    s += a[i]
    l_sum.append(s)

c_sum = Counter(l_sum)

# print(c_sum)
ans = 0
for i in c_sum:
    if c_sum[i] > 1:
        ans += c_sum[i] * (c_sum[i] - 1) // 2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

ans = 0
for i in range(n):
    for j in range(i, n):
        if sum(a[i:j+1]) == 0:
            ans += 1

print(ans)

Fixed submission:
from collections import Counter

n = int(input())
a = list(map(int, input().split()))

l_sum = [0]
s= 0
for i in range(n):
    s += a[i]
    l_sum.append(s)

c_sum = Counter(l_sum)

# print(c_sum)
ans = 0
for i in c_sum:
    if c_sum[i] > 1:
        ans += c_sum[i] * (c_sum[i] - 1) // 2

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x = list(map(int, input().split()))

m = int(n/2)-1
x_tmp = sorted(x)
# print(x_tmp)

for i in range(n):
    if x_tmp.index(x[i]) > m:
        print(x_tmp[m])
    else:
        print(x_tmp[m+1])


Fixed submission:
from heapq import heappush, heappop

n = int(input())
x = list(map(int, input().split()))

m = int(n/2)-1
x_tmp = sorted(x)

for i in range(n):
    if x[i] <= x_tmp[m]:
        print(x_tmp[m+1])
    else:
        print(x_tmp[m])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x = list(map(int, input().split()))

m = int(n/2)-1
for i in range(n):
    x_tmp = x[:i] + x[i+1:]
    x_tmp.sort()
    print(x_tmp[m])


Fixed submission:
from heapq import heappush, heappop

n = int(input())
x = list(map(int, input().split()))

m = int(n/2)-1
x_tmp = sorted(x)

for i in range(n):
    if x[i] <= x_tmp[m]:
        print(x_tmp[m+1])
    else:
        print(x_tmp[m])