Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
x = input()
while ("ST" in x):
    x = x.replace("ST", '')
print(len(x))

Fixed submission:
x = input()
ans = []
for i in range(len(x)):
    if (x[i] == "S"):
        ans.append("S")
    else:
        if (len(ans) != 0):
            if (ans[-1] == "S"):
                ans.pop(-1)
            else:
                ans.append("T")
        else:
            ans.append("T")
print(len(ans))

Buggy python submission (verdict: Time Limit Exceeded):
x = input()
while ("ST" in x):
    x = x.replace("ST", '',1 )
print(len(x))

Fixed submission:
x = input()
ans = []
for i in range(len(x)):
    if (x[i] == "S"):
        ans.append("S")
    else:
        if (len(ans) != 0):
            if (ans[-1] == "S"):
                ans.pop(-1)
            else:
                ans.append("T")
        else:
            ans.append("T")
print(len(ans))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
import bisect
from sys import stdin,stdout
from math import gcd,floor,sqrt,log
from collections import defaultdict as dd
from bisect import bisect_left as bl,bisect_right as br

sys.setrecursionlimit(100000000)

ii     =lambda: int(input())
si     =lambda: input()
jn     =lambda x,l: x.join(map(str,l))
sl     =lambda: list(map(str,input().strip()))
mi     =lambda: map(int,input().split())
mif    =lambda: map(float,input().split())
lii    =lambda: list(map(int,input().split()))

ceil   =lambda x: int(x) if(x==int(x)) else int(x)+1
ceildiv=lambda x,d: x//d if(x%d==0) else x//d+1

flush  =lambda: stdout.flush()
stdstr =lambda: stdin.readline()
stdint =lambda: int(stdin.readline())
stdpr  =lambda x: stdout.write(str(x))

mod=1000000007


#main code
n=ii()
arr=lii()
sol=0
for i in range(n):
    for j in range(i+1,n):
        sol+=(arr[i]*arr[j])
print(sol%mod)

Fixed submission:
import sys
import math
import bisect
from sys import stdin,stdout
from math import gcd,floor,sqrt,log
from collections import defaultdict as dd
from bisect import bisect_left as bl,bisect_right as br

sys.setrecursionlimit(100000000)

ii     =lambda: int(input())
si     =lambda: input()
jn     =lambda x,l: x.join(map(str,l))
sl     =lambda: list(map(str,input().strip()))
mi     =lambda: map(int,input().split())
mif    =lambda: map(float,input().split())
lii    =lambda: list(map(int,input().split()))

ceil   =lambda x: int(x) if(x==int(x)) else int(x)+1
ceildiv=lambda x,d: x//d if(x%d==0) else x//d+1

flush  =lambda: stdout.flush()
stdstr =lambda: stdin.readline()
stdint =lambda: int(stdin.readline())
stdpr  =lambda x: stdout.write(str(x))

mod=1000000007


#main code
def findProductSum(A, n): 
    array_sum = 0
    for i in range(0, n, 1): 
        array_sum = array_sum + A[i] 
    array_sum_square = array_sum * array_sum 
    individual_square_sum = 0
    for i in range(0, n, 1): 
        individual_square_sum += A[i] * A[i] 
    return (array_sum_square - 
            individual_square_sum)//2
n=ii()
arr=lii()
print(findProductSum(arr,n)%mod)
Buggy python submission (verdict: Runtime Error):
s=input()
count=0
flag=True
if s[0]=='R' and s[1]=='R' and s[2]=='R':
    print(3)
elif (s[0]=='R' and s[1]=='R') or (s[0]=='R' and s[2]=='R') 
or(s[1]=='R' and s[2]=='R'):
    print(2)
elif s[0]=='R' or s[1]=='R' or s[2]=='R':
    print(1)
else:
    print(0)

Fixed submission:
s=input()
count=0
sa=0
for char in s:
    if char=='R':
        sa+=1
    else:
        sa=0
    count=max(sa,count)
print(count)
Buggy python submission (verdict: Runtime Error):
def main():
  n, m = map(int, input().split())
  l = list(map(int, input().split()))
  d = sum(l) / 4 / m
  l.sort()
  for i in l:
    if l[i] < d:
      print ("No")
      return
  print ("Yes")
  return

if __name__ == '__main__':
    main()

Fixed submission:
import sys
def main():
  n, m = map(int, input().split())
  l = list(map(int, input().split()))
  d = sum(l) / (4 * m)
  cnt = 0;
  for li in l:
    if li >= d:
      cnt = cnt + 1
  if cnt >= m :
    print ("Yes")
  else :
    print ("No")
  return

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
t = int(input())
s = [int(i) for i in input().split()]
c = 0
for i in range(1, t):
  c += sum(s[:i]) * s[i]
mod = 10**9 + 7
print(c%mod)

Fixed submission:
t = int(input())
s = [int(i) for i in input().split()]
c = 0
n = s[0]
for i in range(1, t):
  c += n * s[i]
  n += s[i]
mod = 10**9 + 7
print(c%mod)
Buggy python submission (verdict: Runtime Error):
x,n = [int(i) for i in input().split()]
if n == 0:
  print(x)
  exit()
p = [int(i) for i in input().split()]

num = list(range(1,101))
nums = []
for i in num:
  if not(i in p):
    nums.append(i)
#print(nums)
p2 = [abs(nums[i]-x) for i in range(len(nums))]
p2min = min(p2)
for i in range(len(p2)):
  if p2[i] == p2min:
    print(nums[i])
    exit()


Fixed submission:
x,n = [int(i) for i in input().split()]
if n == 0:
  print(x)
  exit()
p = [int(i) for i in input().split()]

num = list(range(102))
nums = []
for i in num:
  if not(i in p):
    nums.append(i)
#print(nums)
p2 = [abs(nums[i]-x) for i in range(len(nums))]
p2min = min(p2)
for i in range(len(p2)):
  if p2[i] == p2min:
    print(nums[i])
    exit()
Buggy python submission (verdict: Runtime Error):
s=input()
n=len(s)
if not(s==s[::-1]):
  print(No)
  exit()
if not(s[:1+(n-1)/2]==s[:1+(n-1)/2][::-1]):
  print(No) 
  exit()
if not(s[(n+3)/2:]==s[(n+3)/2:]):
  print(No)
  exit()
print(Yes)

       

Fixed submission:
s=input()
n=len(s)
if not(s==s[::-1]):
  print("No")
  exit()
if not(s[:(n-1)//2]==s[:(n-1)//2][::-1]):
  print("No") 
  exit()
if not(s[(n+3)//2-1:]==s[(n+3)//2-1:][::-1]):
  print("No")
  exit()
print("Yes")
Buggy python submission (verdict: Runtime Error):
print((int(input())/3)**3

Fixed submission:
print((int(input())/3)**3)
Buggy python submission (verdict: Runtime Error):
n,r = input()
n,r = input().split()
n = min(10,int(n))
r = int(r)
r = r+100*(10-n)
print(r)


Fixed submission:
n,r = input().split()
n = min(10,int(n))
r = int(r)
r = r+100*(10-n)
print(r)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
luk = input()

keys = [str(i)+str(j)+str(k) for i in range(10) for j in range(10) for k in range(10)]
a = 0
for key in keys:
  s = 0
  for st in luk:
    if st == key[s]:
      s += 1
    if s == 3:
      a += 1
      s = 0
      break
print(a)

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

keys = [str(i)+str(j)+str(k) for i in range(10) for j in range(10) for k in range(10)]
a = 0
for key in keys:
  s = 0
  for st in luk:
    if st == key[s]:
      s += 1
    if s == 3:
      a += 1
      s = 0
      break
print(a)
Buggy python submission (verdict: Runtime Error):
a,b,x = [int(x) for x in input().split()]
sq = x/a
sq2 = a*b - sq
if sq2 <= a*b/2:
  line = sq2*2/a
  import math 
  #print(sq,sq2,line)
  t = 90-math.degrees(math.atan(a/line))
  print(t)
else:
  line = sq*2/b
  import math 
  #print("a",sq,sq2,line)
  t = 90-math.degrees(math.atan(line/b))
  print(t)

Fixed submission:
a,b,x = [int(x) for x in input().split()]
sq = x/a
sq2 = a*b - sq
if sq2 <= a*b/2:
  line = sq2*2/a+0.00000001
  import math 
  #print(sq,sq2,line)
  t = 90-math.degrees(math.atan(a/line))
  print(t)
else:
  line = sq*2/b+0.00000001
  import math 
  #print("a",sq,sq2,line)
  t = 90-math.degrees(math.atan(line/b))
  print(t)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
h = [int(x) for x in input().split()]
for i in range(1,N+1):
  print(h.index(i)+1,"",end="")


Fixed submission:
N = int(input())
h = [int(x) for x in input().split()]
t= [0]*N
for i in range(1,N+1):
  t[h[i-1]-1]=i
print(*t)
Buggy python submission (verdict: Runtime Error):
N = int(input())
print(sum(list(range(N))))


Fixed submission:
N = int(input())
print(sum(range(N)))
Buggy python submission (verdict: Runtime Error):
N, K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
mod = 10**9+7
B = A*2
c = 0
for i in range(len(B)):
  t = B[i]
  for j in range(1,len(B[i:])):
    if t > B[i+j]:
      c += 1
      #print(t,B[i+j])
#print(c)
s = sum(range(K))
print((c%mod*s%mod)%mod)

Fixed submission:
M, D = [int(x) for x in input().split()]
dates = list(range(22,D+1))
c = 0
 
for i in range(len(dates)):
  d1 = int(str(dates[i])[-1])
  d2 = int(str(dates[i])[-2])
  if d1*d2 <= M and d1 > 1 and d2 > 1:
    #print(d2,d1)
    c += 1
print(c)
Buggy python submission (verdict: Runtime Error):
A,B = map(int,input())
print(max(A*B,A-B,A+B))

Fixed submission:
A,B = map(int,input().split())
print(max(A*B,A-B,A+B))
Buggy python submission (verdict: Runtime Error):
N = int(input())
p = [int(x) for x in input().split()]
a = sorted(P)
c = 0
for i in range(N):
  if p[i] != a[i]:
    c+=1
if c <= 2 :
  print("YES")
if c >3:
  print("No")
    

Fixed submission:
N = int(input())
p = [int(x) for x in input().split()]
a = sorted(p)

c = 0
for i in range(N):
  if p[i] != a[i]:
    c += 1
if c <= 2 :
  print("YES")
if c > 2:
  print("NO")
Buggy python submission (verdict: Runtime Error):
from collections import deque
 
N, M = map(int, input().split())
 
vec = [[] for _ in range(N)]
for _ in range(M) :
    u, v = map(int, input().split())
    vec[u-1].append(v-1)
 
S, T = map(int, input().split())
S, T = S - 1, T - 1
 
visited = [[False] * N for _ in range(3)]
visited[0][S] = True
queue = deque([(S, 0)])
 
while queue :
    #print(queue)
    q, cost = queue.popleft()
    #print(q,cost)
    #print("vec[q] =",vec[q])
    p = (cost + 1) % 3
    for i in vec[q] :
        if p == 0 and i == T :
            
            print((cost + 1) // 3)
            exit()
        if not visited[p][i] :
            visited[p][i] = True
            #print(visited)
            #print(i)
            queue.append((i, cost + 1))
 
print(-1)

Fixed submission:
a = str(input())
b=list(set(a))

if len(b) == 2:
  count = 0
  for i in range(1,4):
    if a[i] == a[0]:
      count +=1
  if count ==1:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
from collections import deque
 
N, M = map(int, input().split())
 
vec = [[] for _ in range(N)]
for _ in range(M) :
    u, v = map(int, input().split())
    vec[u-1].append(v-1)
 
S, T = map(int, input().split())
S, T = S - 1, T - 1
 
visited = [[False] * N for _ in range(3)]
visited[0][S] = True
queue = deque([(S, 0)])
 
while queue :
    #print(queue)
    q, cost = queue.popleft()
    #print(q,cost)
    #print("vec[q] =",vec[q])
    p = (cost + 1) % 3
    for i in vec[q] :
        if p == 0 and i == T :
            
            print((cost + 1) // 3)
            exit()
        if not visited[p][i] :
            visited[p][i] = True
            #print(visited)
            #print(i)
            queue.append((i, cost + 1))
 
print(-1)

Fixed submission:
a = str(input())
b=list(set(a))

if len(b) == 2:
  count = 0
  for i in range(1,4):
    if a[i] == a[0]:
      count +=1
  if count ==1:
    print("Yes")
  else:
    print("No")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())
nump = input().split()
nump = [int(i) for i in nump]

count = 0
for i in range(1,8):
  p = nump[i]
  tmp = sorted([nump[i-1],nump[i],nump[i+1]])
  if tmp[1] == p:
    count+=1
print(count)


Fixed submission:
N = int(input())
nump = input().split()
nump = [int(i) for i in nump]

count = 0
for i in range(1,N-1):
  p = nump[i]
  tmp = nump[i-1:i+2]
  tmp.sort()
  if tmp[1] == p:
    count+=1
print(count)

Buggy python submission (verdict: Runtime Error):
N = int(input())
nump = input().split()
nump = [int(i) for i in nump]

count = 0
for i in range(1,8):
  p = nump[i]
  tmp = sorted([p[i-1],p[i],[i+1]])
  if tmp[1] == p:
    count+=1
print(count)


Fixed submission:
N = int(input())
nump = input().split()
nump = [int(i) for i in nump]

count = 0
for i in range(1,N-1):
  p = nump[i]
  tmp = nump[i-1:i+2]
  tmp.sort()
  if tmp[1] == p:
    count+=1
print(count)

Buggy python submission (verdict: Runtime Error):
N = int(input())
nump = input().split()
nump = [int(i) for i in nump]

count = 0
for i in range(1,8):
  p = p[i]
  tmp = sorted([p[i-1],p[i],[i+1]])
  if tmp[1] == p:
    count+=1
print(count)


Fixed submission:
N = int(input())
nump = input().split()
nump = [int(i) for i in nump]

count = 0
for i in range(1,N-1):
  p = nump[i]
  tmp = nump[i-1:i+2]
  tmp.sort()
  if tmp[1] == p:
    count+=1
print(count)
Buggy python submission (verdict: Runtime Error):
N = int(input())
ds = input().split()
ds = [int(i) for i in ds]
ds.sort()
#print(ds)
#if ds[int(N/2)] == ds[int(N/2)+1]:
#  print("0")
#else:
print(ds[int(N/2)+1]-ds[int(N/2)])

Fixed submission:
N = int(input())
ds = input().split()
ds = [int(i) for i in ds]
ds.sort()
#print(ds)
#if ds[int(N/2)] == ds[int(N/2)+1]:
#  print("0")
#else:
print(ds[int(N/2)]-ds[int(N/2)-1])

Buggy python submission (verdict: Runtime Error):
N = int(input())
ds = input().split()
ds = [int(i) for i in ds]
ds.sort()
#print(ds)
if ds[int(N/2)] == ds[int(N/2)+1]:
  print("0")
else:
  print("1")

Fixed submission:
N = int(input())
ds = input().split()
ds = [int(i) for i in ds]
ds.sort()
#print(ds)
#if ds[int(N/2)] == ds[int(N/2)+1]:
#  print("0")
#else:
print(ds[int(N/2)]-ds[int(N/2)-1])
Buggy python submission (verdict: Runtime Error):
lock_num = list(input())
#lock_num = [int(x) for x in lock_num]
tag = 0
for i in range(3):
  if int(lock_num[i]) == int(lock_num[i+1]):
    tag = 1
if tag == 0:
  print("Good")
else tag ==1:
  print("Bad")

Fixed submission:
lock_num = input()
#lock_num = [int(x) for x in lock_num]
tag = 0
for i in range(3):
  if int(lock_num[i]) == int(lock_num[i+1]):
    tag = 1
    break
if tag == 0:
  print("Good")
else:
  print("Bad")

Buggy python submission (verdict: Runtime Error):
lock_num = input()
#lock_num = [int(x) for x in lock_num]
tag = 0
for i in range(len(lock_num)-1):
  if int(lock_num[i]) == int(lock_num[i+1]):
    tag = 1
if tag == 0:
  print("Good")
else tag ==1:
  print("Bad")

Fixed submission:
lock_num = input()
#lock_num = [int(x) for x in lock_num]
tag = 0
for i in range(3):
  if int(lock_num[i]) == int(lock_num[i+1]):
    tag = 1
    break
if tag == 0:
  print("Good")
else:
  print("Bad")

Buggy python submission (verdict: Runtime Error):
lock_num = input().split()
lock_num = [int(x) for x in lock_num]
tag = 0
for i in range(len(lock_num)-1):
  if lock_num[i] == lock_num[i+1]:
    tag = 1
if tag == 0:
  print("Good")
else tag ==1:
  print("Bad")

Fixed submission:
lock_num = input()
#lock_num = [int(x) for x in lock_num]
tag = 0
for i in range(3):
  if int(lock_num[i]) == int(lock_num[i+1]):
    tag = 1
    break
if tag == 0:
  print("Good")
else:
  print("Bad")
Buggy python submission (verdict: Runtime Error):
N, L = input().split()
apples = [x + int(L) for x in list(range(int(N)))]
abs_min_index = [abs(x) for x in apples].index(min(abs_apples))
print(sum(apples) - apples[abs_min_index])

Fixed submission:
N, L = input().split()
N = int(N)
L = int(L)

apples = list(range(N)) 
apples = [x + L for x in apples]
abs_apples = [abs(x) for x in apples]
abs_min_index = abs_apples.index(min(abs_apples))

print(sum(apples) - apples[abs_min_index])

Buggy python submission (verdict: Runtime Error):
N, L = input().split()
apples = [x + int(L) for x in list(range(int(N))]
abs_apples = [abs(x) for x in apples]
abs_min_index = abs_apples.index(min(abs_apples))
print(sum(apples) - apples[abs_min_index])

Fixed submission:
N, L = input().split()
N = int(N)
L = int(L)

apples = list(range(N)) 
apples = [x + L for x in apples]
abs_apples = [abs(x) for x in apples]
abs_min_index = abs_apples.index(min(abs_apples))

print(sum(apples) - apples[abs_min_index])

Buggy python submission (verdict: Runtime Error):
N, L = input().split()
apples = [x + int(L) for x in list(range(int(N))
abs_apples = [abs(x) for x in apples]
abs_min_index = abs_apples.index(min(abs_apples))
print(sum(apples) - apples[abs_min_index])

Fixed submission:
N, L = input().split()
N = int(N)
L = int(L)

apples = list(range(N)) 
apples = [x + L for x in apples]
abs_apples = [abs(x) for x in apples]
abs_min_index = abs_apples.index(min(abs_apples))

print(sum(apples) - apples[abs_min_index])

Buggy python submission (verdict: Runtime Error):
N, L = input().split()
N = int(N)
L = int(L)

apples = list(range(N)) + L
abs_min = min([abs(x) for x in apples])
print(sum[apples] - abs_min*2)

Fixed submission:
N, L = input().split()
N = int(N)
L = int(L)

apples = list(range(N)) 
apples = [x + L for x in apples]
abs_apples = [abs(x) for x in apples]
abs_min_index = abs_apples.index(min(abs_apples))

print(sum(apples) - apples[abs_min_index])
Buggy python submission (verdict: Runtime Error):
W,H,x,y = input().split()
W = int(W)
H = int(H)
x = int(x)
y = int(y)

print("{} 0".format(W*H/2)

Fixed submission:
W,H,x,y = input().split()
W =float(W)
H = float(H)
x = float(x)
y = float(y)
sq = W*H/2
if x == W/2 and y == H/2:
  print("{} 1".format(sq))
else:
  print("{} 0".format(sq))

Buggy python submission (verdict: Runtime Error):
W,H,x,y = input().split()
W = int(W)
H = int(H)
x = int(x)
y = int(y)

print("{} 0".format(W*H/2)	

Fixed submission:
W,H,x,y = input().split()
W =float(W)
H = float(H)
x = float(x)
y = float(y)
sq = W*H/2
if x == W/2 and y == H/2:
  print("{} 1".format(sq))
else:
  print("{} 0".format(sq))

Buggy python submission (verdict: Runtime Error):
W,H,x,y = input().split()
W = int(W)
H = int(H)
x = int(x)
y = int(y)

if W/2 > x:
  sq1 = x * H
else:
  sq1 = (W-x) * H
  
if H/2 > y:
  sq2 = y * W
else:
  sq2 = (H-y) * W
if sq1 == sq2:
  print("{} 1".format(sq1))
elif sq1 > sq2:
  #print("{} 0".format(sq1))
#else:
 # print("{} 0".format(sq2))



Fixed submission:
W,H,x,y = input().split()
W =float(W)
H = float(H)
x = float(x)
y = float(y)
sq = W*H/2
if x == W/2 and y == H/2:
  print("{} 1".format(sq))
else:
  print("{} 0".format(sq))
Buggy python submission (verdict: Runtime Error):
print(hello)

Fixed submission:
x = input().split()
sum1 = int(x[0]) + int(x[1])
sum2 = int(x[1]) + int(x[2])
sum3 = int(x[0]) + int(x[2])
print(min(sum1, sum2, sum3))
Buggy python submission (verdict: Runtime Error):
n = int(input()) 
a = [0 for i in range(15)]
alf = "abcdefghijklmnopqrstuvwxyz" 
hasStarted = False
hasFound = False
for j in range(14, -1, -1):
	rem = n // (26**j)
	if rem == 0:
		continue
	else:
		a[j] = rem
		n -= rem*(26**j)
a.reverse()
res = ""
for c in a:
	if hasStarted:
		if c == 0:
			res += "z"
		else:
			res += alf[c-1]
	else:
		if c != 0:
			res += alf[c-1]
			hasStarted = True

print(res)


Fixed submission:
a = input()
if a.islower():
  print("a")
else:
  print("A")
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
q = int(input())
d = dict()
s = 0
for num in a:
  if num in d:
    d[num] += 1
  else:
    d[num] = 1
  s += num
for i in range(q):
  B, C = list(map(int, input().split()))
  if B in d:
    if C in d:
      d[C] += d[B]
    else:
      d[C] = d[B]
    s += (C-B)*d[B]
    s[B] = 0
  print(s)

Fixed submission:
n = int(input())
a = input().split()
q = int(input())
d = dict()
s = 0
for num in a:
  if num in d:
    d[num] += 1
  else:
    d[num] = 1
  s += int(num)
for i in range(q):
  B, C = input().split()
  if B in d:
    if C in d:
      d[C] += d[B]
    else:
      d[C] = d[B]
    s += (int(C)-int(B))*d[B]
    d[B] = 0
  print(s)
Buggy python submission (verdict: Time Limit Exceeded):
A, B, C, D = list(map(int, input().split()))


while True:
  C -= B
  if C <= 0:
    print("Yes")
  A -= D
  if A <= 0:
    print("No")

Fixed submission:
from math import ceil

A, B, C, D = list(map(int, input().split()))

tak = ceil(C / B)
ao = ceil(A / D)

if tak <= ao:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
import math

r = int(input())

print(r*2*math.PI)

Fixed submission:
import math

r = int(input())

print(2*r*math.pi)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [0]*n
for i in range(1, n+1):
  if i % 3 == 0 or i % 5 == 0:
    pass
  else:
    a[i] = i
print(sum(a))
  

Fixed submission:
n = int(input())
a = [0]*n
for i in range(1, n+1):
  if i % 3 == 0 or i % 5 == 0:
    pass
  else:
    a[i-1] = i
print(sum(a))
Buggy python submission (verdict: Runtime Error):
#500-1000, 5-5

x = int(input())
fiveHundred = x//500
x -= fiveHundred*500
fives = x//5
print(fiveHundred*1000+fives*5)


Fixed submission:
s = input()

if s[2]==s[3] and s[4] == s[5]:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# coding: utf-8

# In[13]:


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


# In[14]:


mod = 10**9+7
a_sum = sum(A)
mylist = [(a_sum-sum(A[:i+1]))*a for i,a in enumerate(A)]
ans = sum(mylist)%mod
print(ans)


# In[ ]:






Fixed submission:
#!/usr/bin/env python
# coding: utf-8

# In[23]:


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


# In[24]:


mod = 10**9+7
a_sum = sum(A)
a_sum_list = []
cnt = 0
for i,a in enumerate(A):
    a_sum_list += [a_sum-a-cnt]
    cnt += a
mylist = [a_sum_list[i]*a for i,a in enumerate(A)]
ans = sum(mylist)%mod
print(ans)


# In[ ]:
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[140]:


def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def unite(x,y):
    x = find(x)
    y = find(y)
    if x == y:
        return False
    if par[x] > par[y]:
        x,y = y,x
    par[x] += par[y]
    par[y] = x
    return True

def size(x):
    return -par[find(x)]


# In[144]:


par = [-1]*N
N,M = map(int, input().split())
for _ in range(M):
    A,B = map(int, input().split())
    A -= 1; B -= 1
    unite(A,B)
ans = 0
for i in range(N):
    ans = max(ans, size(i))
print(ans)


# In[ ]:






Fixed submission:
#!/usr/bin/env python
# coding: utf-8

# In[1]:


def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def unite(x,y):
    x = find(x)
    y = find(y)
    if x == y:
        return False
    if par[x] > par[y]:
        x,y = y,x
    par[x] += par[y]
    par[y] = x
    return True

def size(x):
    return -par[find(x)]


# In[3]:


N,M = map(int, input().split())
par = [-1]*N
for _ in range(M):
    A,B = map(int, input().split())
    A -= 1; B -= 1
    unite(A,B)
ans = 0
for i in range(N):
    ans = max(ans, size(i))
print(ans)


# In[ ]:
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# coding: utf-8

# In[32]:


K = int(input())


# In[33]:


if K%2 == 0 or K%5 == 0:
    print(-1)
else:
    for i in range(1,K+1):
        if int("7"*i)%K == 0:
            print(i)
            break
    else:
        print(-1)


# In[ ]:






Fixed submission:
#!/usr/bin/env python
# coding: utf-8

# In[40]:


K = int(input())


# In[44]:


if K%2 == 0 or K%5 == 0:
    print(-1)
else:
    if K%7 == 0:
        L = 9*K//7
    else:
        L = 9*K
    ans = -1
    tmp = 0
    for i in range(1,K+1):
        if (10*tmp+9)%L == 0:
            ans = i
            break
        else:
            tmp = (10*tmp+9)%L
    print(ans)


# In[ ]:
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# coding: utf-8

# In[2]:


import collections


# In[18]:


N = int(input())
clist = input()


# In[19]:


c = collections.Counter(clist)
cr = c["R"]
mylist = [x for x in clist]
mylist_r = list(reversed(mylist))
ans = 0
while mylist[:cr].count("R") != cr:
    W_i = mylist.index("W")
    R_i = mylist_r.index("R")
    mylist[W_i] = "R"
    mylist[N-R_i-1] = "W"
    mylist_r[N-W_i-1] = "R"
    mylist_r[R_i] = "W"
    ans += 1
print(ans)


# In[ ]:






Fixed submission:
#!/usr/bin/env python
# coding: utf-8

# In[2]:


import collections


# In[26]:


N = int(input())
clist = input()


# In[27]:


c = collections.Counter(clist)
cr = c["R"]
# mylist = [x for x in clist]
# mylist_r = list(reversed(mylist))
# ans = 0
# while mylist[:cr].count("R") != cr:
#     W_i = mylist.index("W")
#     R_i = mylist_r.index("R")
#     mylist[W_i] = "R"
#     mylist[N-R_i-1] = "W"
#     mylist_r[N-W_i-1] = "R"
#     mylist_r[R_i] = "W"
#     ans += 1
# print(ans)
ans = clist[:cr].count("W")
print(ans)


# In[ ]: