Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
flag = 0
ans = 1
for i in range(N):
    ans *= A[i]
    if ans > 10**18:
        flag = 1
    if A[i] == 0:
        flag = 2
if flag == 0:
    print(ans)
elif flag == 1:
    print(-1)
else:
    print(0)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
flag = 0
ans = 1
for i in range(N):
    if flag == 0:
        ans *= A[i]
    if ans > 10**18 and flag != 2:
        flag = 1
    if A[i] == 0:
        flag = 2
if flag == 0:
    print(ans)
elif flag == 1:
    print(-1)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
S = input()

if S == ABC:
    print("ARC")
else:
    print("ABC")

Fixed submission:
S = input()

if S == "ABC":
    print("ARC")
else:
    print("ABC")
Buggy python submission (verdict: Time Limit Exceeded):
N,M =list(map(int,input().split()))
H = list(map(int,input().split()))

h = [[0] * N for i in range(N)]
ans = 0
for i in range(M):
    A,B = list(map(int,input().split()))
    h[A-1][B-1] = H[B-1]
    h[B-1][A-1] = H[A-1]

for i in range(N):
    if H[i] >max(h[i]) or max(h[i])== 0:
        ans += 1
print(ans)

Fixed submission:
N,M =list(map(int,input().split()))
H = list(map(int,input().split()))

h = [0] * N 
ans = 0
for i in range(M):
    A,B = list(map(int,input().split()))
    h[A-1] = max(H[B-1],h[A-1])
    h[B-1] = max(H[A-1],h[B-1])

for i in range(N):
    if H[i] >h[i] or h[i] == 0:
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
X = int(input())
a = 0
while True:
    c  = (X -a**5)**0.2
    b = int(c)
    if c - b < 0.01:
        print(a,-b)
        break
    a += 1

Fixed submission:
X = int(input())
a = 0
while True:
    a5 = a**5
    d  = X-a5
    if d >= 0:
        c  = d**0.2
        b1 = int(c)
        b2 = b1+1
        if a5 + b1**5 == X:
            print(a,-b1)
            break
        if a5 + b2**5 == X:
            print(a,-b2)
            break
    else:
        c = ((-d)**0.2)
        b1 = int(c)
        b2 = b1+1
        if a5 - b1**5 == X:
            print(a,b1)
            break
        if a5 - b2**5 == X:
            print(a,b2)
            break
    a += 1
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
d = [0]*2*10*9
ans = 0
for i in range(N):
    d[i+1+A[i]] += 1
    
for i in range(1,N+1):
    f = A[-i]+N+1-i-(2*A[-i])
    if f >= 0:
        ans += d[f]
print(ans)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
d = [0]*(10**6)
ans = 0
for i in range(N):
    m = i+1+A[i]
    if m < 10**6:
        d[i+1+A[i]] += 1
    
for i in range(1,N+1):
    f = A[-i]+N+1-i-(2*A[-i])
    if f >= 0 and f < 10**6:
        ans += d[f]
print(ans)
Buggy python submission (verdict: Runtime Error):
S,W = list(map(int,input().split()))

if S =< W:
    print("unsafe")
else:
    print("safe")

Fixed submission:
S,W = list(map(int,input().split()))

if S <= W:
    print("unsafe")
else:
    print("safe")
Buggy python submission (verdict: Runtime Error):
inp = list(map(int,input().split()))
 
a = inp[0]*inp[1]

if (inp[0]==1 or inp[1]==1):
    print("1")
else:
    if (a %2 == 1):
        b = int(a/2)+1
    else:
        b = a/2
 
print(b)


Fixed submission:
inp = list(map(int,input().split()))
 
a = inp[0]*inp[1]

if (inp[0]==1 or inp[1]==1):
    print("1")
else:
    if (a %2 == 1):
        b = int(a/2)+1
        print('{:.19g}'.format(b))
    else:
        b = a/2
        print('{:.19g}'.format(b))
Buggy python submission (verdict: Runtime Error):
if (inp[0]<8000000000):
    if (inp[0]+inp[1]-inp[2] < -2 * (inp[0]*inp[1])**0.5):
        print("Yes")
    else:
        print("No")
else:
    if(inp[0]**2+inp[1]**2+inp[2]**2-2*(inp[0]*inp[1]+inp[1]*inp[2]+inp[0]*inp[1])<0):
        print("No")
    else:
        print("Yes")

Fixed submission:
inp = list(map(int,input().split()))
a =inp[0]
b = inp[1]
c = inp[2]
if (c - a- b > 0):
    if (0< a**2 +b**2 + c**2- 2*(a*b + b*c + a*c)):
        print("Yes")
    else:
        print("No")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
Input = list(map(int,input().split()))

point =[]
for i in range(Input[0]):
    point.append(0)

for i in range(Input[2]):
    aa = int(input())
    point[aa-1] +=1
gouhi =[]
for i in range(Input[0]):
    bb = 0
    if Input[1]-Input[2]+point[i] > 0 :
        bb = "Yes"
    else:
        bb = "No"
    gouhi.append(bb)
print("\n".join(gouhi))

Fixed submission:
Input = int(input())

aa = int(Input**0.5)

for i in range(1,aa+1):
  if Input%(aa+1-i) == 0:
    num1 = aa+1-i
    num2 = Input/(aa+1-i)
    break
print(int(num1 + num2 -2))
Buggy python submission (verdict: Runtime Error):
import math
Input = list(map(int,input().split()))
a = Input[0]
b = Input[1]
x = Input[2]

taiseki = a**2*b

if x>taiseki/2:
    theta = -math.atan(x/(a**2*(b-a)))
else:
    theta = math.atan(x/(a**2*b))
print(theta)


Fixed submission:
import math
Input = list(map(int,input().split()))
a = Input[0]
b = Input[1]
x = Input[2]

taiseki = a**2*b

if x<=taiseki/2:
    theta = 90-math.degrees(math.atan(2*x/(a*b**2)))
else:
    theta = math.degrees(math.atan(-2*(x-a**2*b)/a**3))
print(theta)
Buggy python submission (verdict: Time Limit Exceeded):
Input = list(map(int,input().split()))

point =[]
for i in range(Input[0]):
    point.append(Input[1])

for i in range(Input[2]):
    aa = int(input())-1
    
    for k in range(Input[0]):
        point[k] -= 1
    
    point[aa] += 1
gouhi =[]
for i in range(Input[0]):
    bb = 0
    if point[i] > 0:
        bb = "Yes"
    else:
        bb = "No"
    gouhi.append(bb)
print("\n".join(gouhi))

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

point =[]
for i in range(Input[0]):
    point.append(0)

for i in range(Input[2]):
    aa = int(input())
    point[aa-1] +=1
gouhi =[]
for i in range(Input[0]):
    bb = 0
    if Input[1]-Input[2]+point[i] > 0 :
        bb = "Yes"
    else:
        bb = "No"
    gouhi.append(bb)
print("\n".join(gouhi))
Buggy python submission (verdict: Runtime Error):
N = int(input())
count = 0
c = 0
for i in range(N):
    d1,d2 = input().split()
    if d1==d2:
        count+=1
        if count==3:
            c =1

    else:
        count=0
if c==1:
    print('Yes')
else:
    print('No')

Fixed submission:
S = input()
if S[-1]=='s':
    s = S+'es'
else:
    s = S+'s'
print(s)

Buggy python submission (verdict: Runtime Error):
N = int(input())
count = 0
c = 0
for i in range(N):
    d1,d2 = input().split()
    if d1==d2:
        count+=1
        if count==3:
            c =1
            sys.exit()
    else:
        count=0
if c==1:
    print('Yes')
else:
    print('No')

Fixed submission:
S = input()
if S[-1]=='s':
    s = S+'es'
else:
    s = S+'s'
print(s)

Buggy python submission (verdict: Runtime Error):
N = int(input())
count = 0
c = 0
for i in range(N):
    d1,d2 = input().split()
    if d1==d2:
        count+=1
        if count==3:
            c =1
    else:
        count=0
if count==1:
    print('Yes')
else:
    print('No')

Fixed submission:
S = input()
if S[-1]=='s':
    s = S+'es'
else:
    s = S+'s'
print(s)
Buggy python submission (verdict: Runtime Error):
N = int(input())
count = 0
c = 0
for i in range(N):
    d1,d2 = input().split()
    if d1==d2:
        count+=1
        if count==3:
            c =1
            sys.exit()
    else:
        count=0
if count==1:
    print('Yes')
else:
    print('No')

Fixed submission:
N = int(input())
count = 0
c = 0
for i in range(N):
    d1,d2 = input().split()
    if d1==d2:
        count+=1
        if count==3:
            c =1

    else:
        count=0
if c==1:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
N = input()
count = 0
c = 0
for i in range(N):
    d1,d2,d3 = input().split()
    if (d1==d2)&(d2==d3):
        count+=1
        if count=3:
            c =1
            sys.exit()
    else:
        count=0
if count=1:
    print('Yes')
else:
    print('No')

Fixed submission:
N = int(input())
count = 0
c = 0
for i in range(N):
    d1,d2 = input().split()
    if d1==d2:
        count+=1
        if count==3:
            c =1

    else:
        count=0
if c==1:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
N = input()
count = []
for i in range(N):
    d1,d2,d3 = input().split()
    if (d1==d2)&(d2==d3):
        print('Yes')
        sys.exit()
    else:
        count.append(0)
if sum(count)==0:
    print('No')

Fixed submission:
N = int(input())
count = 0
c = 0
for i in range(N):
    d1,d2 = input().split()
    if d1==d2:
        count+=1
        if count==3:
            c =1

    else:
        count=0
if c==1:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
lis = []
a = []
n = int(input())
a = input().split()
a_  = sorted(a,reverse=True)
a_ = list(a_)
for i in a_:
    if len(lis)==0:
        lis.append(int(i))
    elif len(lis)==1:
        lis.append(lis[0])
    else:
        lis_ = sorted(lis,reverse=True)
        lis.append(lis_[1])
lis_.append(lis[1])
print(sum(int(j) for j in lis_))

Fixed submission:
n = input()
if int(n)%1000==0:
    print(0)
else:
    n_ = 1000-(int(n)%1000)
    print(n_)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

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

ans = 1
for i in a:
    ans = ans * i

if ans > 10**18:
    print(-1)
else:
    print(ans)
    

Fixed submission:
n = int(input())

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

ans = 1

if 0 in a:
    ans = 0
else:
    for i in a:
        if ans <= 10**18:
            ans = ans * i
        else:
            break

if ans > 10**18:
    print(-1)
else:
    print(ans)
Buggy python submission (verdict: Runtime Error):
import math

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

def calc_ans(rad):
    x = a**2 + b**2 -2*a*b*math.cos(rad)
    ans = math.sqrt(x)
    return ans

l_w = 2*math.pi/(12*60)
s_w = 2*math.pi/60

long_rad = l_w * (h*60+m)
short_rad = s_w * m

if abs(long_rad-short_rad) >= math.pi:
    rad = 2*math.pi-abs(long_rad-short_rad)
else:
    rad = abs(long_rad-short_rad)

ans = calc_a

Fixed submission:
import math

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

def calc_ans(rad):
    x = a**2 + b**2 -2*a*b*math.cos(rad)
    ans = math.sqrt(x)
    return ans

l_w = 2*math.pi/(12*60)
s_w = 2*math.pi/60

long_rad = l_w * (h*60+m)
short_rad = s_w * m

if abs(long_rad-short_rad) >= math.pi:
    rad = 2*math.pi-abs(long_rad-short_rad)
else:
    rad = abs(long_rad-short_rad)

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

rsl = []
for i in range(1,n):
    rsl.append(a[i-1:].count(i))

for _ in rsl:
    print(_)
print(0)

Fixed submission:
import numpy as np
n = int(input())
a = list(map(int,input().split()))

rsl = np.zeros(n)

for i in a:
    rsl[i-1] += 1

for i in range(n):
    print(int(rsl[i]))

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

rsl = []
for i in range(1,n):
    rsl.append(a.count(i))

for _ in rsl:
    print(_)
print(0)

Fixed submission:
import numpy as np
n = int(input())
a = list(map(int,input().split()))

rsl = np.zeros(n)

for i in a:
    rsl[i-1] += 1

for i in range(n):
    print(int(rsl[i]))

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

rsl = []
for i in range(1,n+1):
    rsl.append(a.count(i))

for _ in rsl:
    print(_)

Fixed submission:
import numpy as np
n = int(input())
a = list(map(int,input().split()))

rsl = np.zeros(n)

for i in a:
    rsl[i-1] += 1

for i in range(n):
    print(int(rsl[i]))
Buggy python submission (verdict: Runtime Error):
k,n = map(int,input().split())
pos = list(map(int,input().split()))

#posの隣同士の差を格納
#最も差が大きいポジションに対して、CCWとCWを考えて、小さいほうを採用

#差を格納
subtract = []
for i in range(n-1):
    subtract.append(pos[i+1]-pos[i])

#差を格納(posの終点～posの始点)
subtract.append(k-pos[n-1]+pos[0])

#差の配列から、最大差のインデックス番号を取得
idx = subtract.index(max(subtract))

if idx == 0:
    rsl = k-pos[idx-1]+pos[0]
else:
    rsl = pos[n-1]-pos[0]

print(rsl)

Fixed submission:
str = input()

if str[2] == str[3] and str[4] == str[5]:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
s = input()

result = re.fullmatch("(hi){1,5}",s)

if result == None:
    print("No")
else:
    print("Yes")

Fixed submission:
import re

s = input()
 
result = re.fullmatch("(hi){1,5}",s)
 
if result == None:
    print("No")
else:
    print("Yes")
Buggy python submission (verdict: Runtime Error):
N,X,M=map(int,input().split())
t=[]
t.append(X)
temp=X
ans=X
for i in range(10**5+100):
    temp=temp**2%M
    if temp in t:
        firstindex=t.index(temp)
        currentindex=len(t)
        firstsum=0
        for i in range(firstindex-1):
            firstsum+=t[i]
        repeatsum=0
        for i in range(firstindex,currentindex):
            repeatsum+=t[i]
        repetition=(n-firstindex)//(currentindex-firstindex)
        lastrep=        (n-firstindex)%(currentindex-firstindex)
        lastsum=0
        for i in range(firstindex,firstindex+lastrep):
            lastsum+=t[i]

    else:
        t.append(temp)
    

print(firstsum+repetition*repeatsum+lastsum)


Fixed submission:
N,X,M=map(int,input().split())
t=[]
t.append(X)
temp=X
ans=X
for i in range(10**5+100):
    temp=temp**2%M
    if temp in t:
        firstindex=t.index(temp)
        currentindex=len(t)
        firstsum=0
        for i in range(firstindex):
            firstsum+=t[i]
        repeatsum=0
        for i in range(firstindex,currentindex):
            repeatsum+=t[i]
        repetition=(N-firstindex)//(currentindex-firstindex)
        lastrep=        (N-firstindex)%(currentindex-firstindex)
        lastsum=0
        for i in range(firstindex,firstindex+lastrep):
            lastsum+=t[i]
        print(firstsum+repetition*repeatsum+lastsum)
        exit()

    else:
        t.append(temp)
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
A=list(map(int,input().split()))
hyouten=[0]*(N+5)

hyouten[K-1]=A[0]
for i in range(1,K):
    hyouten[K-1]*=A[i]

for i in range(K,N):
    hyouten[i]=hyouten[i-1]*A[i]/A[i-K]



for i in range(K,N):

    if hyouten[i] > hyouten[i-1]:
        # print(hyouten[i-1],hyouten[i])
        print("Yes")
    else:
        # print(hyouten[i-1],hyouten[i])
        print("No")
    


Fixed submission:
N,K=map(int,input().split())
A=list(map(int,input().split()))
for i in range(0,N-K):
    if A[i]< A[i+K]:
        print("Yes")
    else:
        print("No")

Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
A=list(map(int,input().split()))
hyouten=[0]*(N+5)

for i in range(K+1,N+1):
    for j in range(i-K,i):
        if hyouten[i]==0:
            hyouten[i]=A[j]
        else:
            hyouten[i]*=A[j]
    prevhyouten=hyouten[i]/A[i-1]*A[i-K-1]
    if hyouten[i] > prevhyouten:
        # print(prevhyouten,hyouten[i])
        print("Yes")
    else:
        # print(prevhyouten,hyouten[i])
        print("No")
    


Fixed submission:
N,K=map(int,input().split())
A=list(map(int,input().split()))
for i in range(0,N-K):
    if A[i]< A[i+K]:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Time Limit Exceeded):
import math
N=int(input())
xyzmax=int(math.sqrt(N))

for n in range(1,N+1):
    ans4n=0
    xmax=int(math.sqrt(n))
    for x in range(1,xmax+1):
        ymax=xmax+1-x
        for y in range(1,ymax+1):    
            zmax=ymax+1-y
            for z in range(1,zmax+1):
                if n==(x+y+z)**2-(x*y+y*z+z*x):
                    ans4n+=1

    print(ans4n)


Fixed submission:
import math
N=int(input())
ans=[0]*(N+1)
tempn=0
xmax=int(math.sqrt(N)+1)
for x in range(1,xmax+1):
    ymax=xmax-x
    for y in range(1,xmax+1):    
        zmax=ymax-y
        for z in range(1,xmax+1):
            tempn=((x+y+z)**2-(x*y+y*z+z*x))
            if tempn <= N:
                ans[tempn]+=1
for i in range(1,(N+1)):
    print(ans[i])
Buggy python submission (verdict: Runtime Error):
import copy
n,k=map(int,input().split())
a=list(map(int,input().split()))
maxed={}
for m in range(0,k):
    temp=[0]*n
    if len(maxed)==n:
        print(' '.join(map(str,a)))
        exit()
    for i in range(0,n):
        d=a[i]
        if d==n:
            temp[i]=n
            maxed[i]=1
        elif d !=0 :
            for x in range(i-d, i+d+1):
                if x >= 0 and x < n :
                    temp[x]+=1
        else:
            temp[i]+=1
    a=copy.copy(temp)

print(' '.join(map(str,a)))


Fixed submission:
a=[]
a=input()
print('%s%s%s'%(a[0],a[1],a[2]))

Buggy python submission (verdict: Runtime Error):
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())

if a<b and b-a <= (v-w)*t:
    print ("YES")
else:
    print("NO")


Fixed submission:
a=[]
a=input()
print('%s%s%s'%(a[0],a[1],a[2]))
Buggy python submission (verdict: Runtime Error):
from queue import Queue
s=input().split(' ')
N=int(s[0])
M=int(s[1])
room_from=[]
room_to=[]

for i in range(M):
  s=input().split(' ')

#道は両方向に使える
  room_from.append(int(s[0]))
  room_to.append(int(s[1]))
  room_from.append(int(s[1]))
  room_to.append(int(s[0]))

#for i in range(2*M):
#  print("from=",room_from[i],"to=",room_to[i])


#最小経路の回答を入れる. ansewr[room_from]=room_to


answer={}
todo={}
temp={}
todoq=Queue(N)

for (i,room) in enumerate(room_to): 
  if room_to[i] == 1:
    todo[room_from[i]]=1

answer.update(todo)

while True:
  for a in todo:
    for (i,room) in enumerate(room_to): 
      if room == a and room_from[i] not in temp and room_from[i] not in answer and room_from[i] != 1:
        temp[room_from[i]]=a
  if len(temp)==0:
    break
  else:
    todo.clear()
    todo.update(temp)
    answer.update(temp)
    temp.clear()
print(answer)
if len(answer)== N-1 :
  print ("Yes")
  for n in answer:
    print (answer[n])
else:
  print ("No")

Fixed submission:
N=input()
n=int(N[-1])
if n in [2,4,5,7,9]:
  print("hon")
elif n in [0,1,6,8]:
  print("pon")
else:
  print("bon")

Buggy python submission (verdict: Runtime Error):
s=input().split(' ')
N=int(s[0])
M=int(s[1])
room_from=[]
room_to=[]

for i in range(M):
  s=input().split(' ')

#道は両方向に使える
  room_from.append(int(s[0]))
  room_to.append(int(s[1]))
  room_from.append(int(s[1]))
  room_to.append(int(s[0]))

#for i in range(2*M):
#  print("from=",room_from[i],"to=",room_to[i])


#最小経路の回答を入れる. ansewr[room_from]=room_to


answer={}
temp={}
for (i,room) in enumerate(room_to): 
  if room_to[i] == 1:
    answer[room_from[i]]=1

temp={}
for n in range(N):
  for a in answer:
    for (i,room) in enumerate(room_to): 
      if room == a and room_from[i] not in temp and room_from[i] not in answer and room_from[i] != 1:
        temp[room_from[i]]=a
  #        print("temp=",temp)
  answer.update(temp)
#  print ("answer=",answer)

if len(answer)== N-1 :
  print ("Yes")
  for n in answer:
    print (answer[n])
else:
  print ("No")


Fixed submission:
N=input()
n=int(N[-1])
if n in [2,4,5,7,9]:
  print("hon")
elif n in [0,1,6,8]:
  print("pon")
else:
  print("bon")
Buggy python submission (verdict: Runtime Error):
N=int(input())
t=[]
x=[]
y=[]
#t.append(0)
#x.append(0)
#y.append(0)
t_cur=0
x_cur=0
y_cur=0

for i in range(N):
  plan=input().split(' ')
  t.append(int(plan[0]))
  x.append(int(plan[1]))
  y.append(int(plan[2]))

for i in range(N):
  t_gap=t[i]-t_cur
  abs(x_gap)=x[i]-x_cur
  abs(y_gap)=y[i]-y_cur

  dist=x_gap+y_gap

#  print("trip=",t[i],x[i],y[i])
#  print("t_gap=",t_gap)
#  print("dist=",dist)
  if (t_gap-dist)>=0 and (t_gap-dist)%2==0:
    t_cur=t[i]
    x_cur=x[i]
    y_cur=y[i]
  else:
    print("No")
    exit()
print("Yes")


Fixed submission:
N=int(input())
t=[]
x=[]
y=[]
#t.append(0)
#x.append(0)
#y.append(0)
t_cur=0
x_cur=0
y_cur=0

for i in range(N):
  plan=input().split(' ')
  t.append(int(plan[0]))
  x.append(int(plan[1]))
  y.append(int(plan[2]))

for i in range(N):
  t_gap=t[i]-t_cur
  x_gap=abs(x[i]-x_cur)
  y_gap=abs(y[i]-y_cur)

  dist=x_gap+y_gap

#  print("trip=",t[i],x[i],y[i])
#  print("t_gap=",t_gap)
#  print("dist=",dist)
  if (t_gap-dist)>=0 and (t_gap-dist)%2==0:
    t_cur=t[i]
    x_cur=x[i]
    y_cur=y[i]
  else:
    print("No")
    exit()
print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))


def findProductSum(A, n):

    product = 0
    for i in range(n):
        for j in range(i+1, n):
            product = product + A[i]*A[j]
    return product%(10**9 + 7)
print(findProductSum(A,N))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))



A_sum = 0
for i in range(0, N, 1):
    A_sum = A_sum + A[i]

A_sum_sq = A_sum * A_sum

idv_sq_sum = 0
for i in range(0, N, 1):
    idv_sq_sum += A[i] * A[i]

Answer = (A_sum_sq -
          idv_sq_sum) // 2
print(Answer%(10**9 + 7))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
num = 0

for a in range(1, n+1):
  for b in range(1, n//a+1):
    c = n - a * b
    if c != 0:
      num += 1

print(num)

Fixed submission:
n = int(input())
num = 0

for a in range(1, n):
  for b in range(n//a):
    num += 1
  if n % a == 0:
    num -= 1

print(num)
Buggy python submission (verdict: Runtime Error):
num = int(input())
line = []

while num >= 27:
  amari = num%26
  num = num//26
  line.append(amari)
if num < 27:
  line.append(num)

  
alpha = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
line.reverse()
for k in line:
  print(alpha[int(k)-1], end = "")

Fixed submission:
let = input()
if let == let.upper():
  print("A")
else:
  print("a")
Buggy python submission (verdict: Runtime Error):
num = int(input())
line = list(map(int,input().split()))
line2 = []
line.sort()
#[3, 8, 11, 16, 24]
for ele in line:
  line2.append(ele)
x = 0


while len(line2) > 0:
  line3 = []
  for k in line:
    if line2[0] != k:
      amari = (line2[0])%k
      line3.append(amari)
      
    else:
      line3.append(0)
    
  line2.remove(line2[0])  
  line3.sort()
  if line3[1] != 0:
    x += 1
print(x)


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

cnt=[0]*(a[-1]+1)
#cntは0が25個続くリスト
for x in a:
  #xは3,8,11,16,24
 for i in range(x,a[-1]+1,x):
  #x = 3ならrange(3, 25, 3) = 3, 6, 9, 12, 15, 18, 21, 24
  
  cnt[i]+=1
  #xの倍数(xを含む)だったら1が足される
ans=0
for x in a:
 if cnt[x]==1:
  ans+=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
num = int(input())
line = input().split()

x = 1
for i in range(num):
  x = x * int(line[i])
  
if x > 10 ** 18:
    print("-1")
else:
  print(x)

Fixed submission:
num = int(input())
line = input().split()

if "0" in line:
  x = 0
else:
  x = 1
  for i in range(num):
    x = x * int(line[i])
    
    if x > 10 ** 18:
      x = -1
      break
  
print(x)

Buggy python submission (verdict: Time Limit Exceeded):
num = int(input())
line = input().rstrip().split()
x = 1

for i in range(num):
  x = x * int(line[i])
if x > 10 ** 18:
    print("-1")
else:
  print(x)

Fixed submission:
num = int(input())
line = input().split()

if "0" in line:
  x = 0
else:
  x = 1
  for i in range(num):
    x = x * int(line[i])
    
    if x > 10 ** 18:
      x = -1
      break
  
print(x)