Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a,b = (int(x) for x in input().split())
s = input()
num = 0

for i in s:
    if int(s)>= 0 and int(s)<= 9:
        num += 1

if a + b == num and s[a] == '-':
    print('Yes')
else:
    print('No')

Fixed submission:
a,b = (int(x) for x in input().split())
s = input()
num = 0

for i in s:
    if i == '-':
        continue
    elif int(i)>= 0 and int(i)<= 9:
        num += 1
    
    

if a + b == num and s[a] == '-':
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

l = [2,1]
i = 2
while True:
    l.append(l[i-1] + l[i-2])
    if i == n:
        print(l[i])
        exit()
    elif i == 0:
        print(2)
        exit()
    elif i == 1:
        print(1)
        exit()
    else:
        i += 1

Fixed submission:
n = int(input())

l = [2,1]
i = 2
while True:
    l.append(l[i-1] + l[i-2])
    if i == n:
        print(l[i])
        exit()
    elif n == 0:
        print(2)
        exit()
    elif n == 1:
        print(1)
        exit()
    else:
        i += 1

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

l = [2,1]
i = 2
while True:
    l.append(l[i-1] + l[i-2])
    if i == n:
        print(l[i])
        exit()
    else:
        i += 1

Fixed submission:
n = int(input())

l = [2,1]
i = 2
while True:
    l.append(l[i-1] + l[i-2])
    if i == n:
        print(l[i])
        exit()
    elif n == 0:
        print(2)
        exit()
    elif n == 1:
        print(1)
        exit()
    else:
        i += 1
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
if a > b:
  print('GREATER')
elif a = b:
  print('EQUAL')
else:
  print('LESS')

Fixed submission:
a = int(input())
b = int(input())
if a > b:
  print('GREATER')
elif a == b:
  print('EQUAL')
else:
  print('LESS')
Buggy python submission (verdict: Runtime Error):
s = list(input())
flagA = False
flagZ = False

if s[0] == 'A':
    flagA = True

# 文字列の両端から探索していきAのうち最左端にあるものZのうち最右端にあるものの要素数を記録　O(N/2)
i = 1
while not (flagA == True and flagZ == True):

    if s[i] == 'A' and flagA == False:
        a = i 
        flagA = True 
    if s[-i] == 'Z' and flagZ == False:
        z = len(s) - i
        flagZ = True
    
    i += 1
print(z-a+1)

Fixed submission:
s = list(input())
flagA = False
flagZ = False

if s[0] == 'A':
    a = 0
    flagA = True

# 文字列の両端から探索していきAのうち最左端にあるものZのうち最右端にあるものの要素数を記録　O(N/2)
i = 1
while not (flagA == True and flagZ == True):

    if s[i] == 'A' and flagA == False:
        a = i 
        flagA = True 
    if s[-i] == 'Z' and flagZ == False:
        z = len(s) - i
        flagZ = True
    
    i += 1
print(z-a+1)
Buggy python submission (verdict: Runtime Error):
n = input().split()

for i in range(len(n)):
    if n[i] == 'C':
        cflag = 1
    elif cflag == 1 and n[i] == 'F':
        print('Yes')
        exit()

print('No')

Fixed submission:
n = input()

cflag = False

for i in range(len(n)):
    if n[i] == 'C':
        cflag = True
    elif cflag == True and n[i] == 'F':
        print('Yes')
        exit()

print('No')
Buggy python submission (verdict: Runtime Error):
x, n = map(int, input().split())
p = list(map(int, input().split()))
ans = 0
p.sort()
for i in range(p[0], p[n - 1] + 1):
    if (i not in p) and abs(x - i) < abs(ans - x):
        ans = i

print(ans)


Fixed submission:
x, n = map(int, input().split())
p = list(map(int, input().split()))
ans = 0

if n == 0:
    print(x)
    exit()

p.sort()

for i in range(p[0] - x, p[n - 1] + x):
    if (i not in p) and abs(x - i) < abs(ans - x):
        ans = i

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ans = 1
if 0 in a:
    print(0)
    exit()
for i in range(n):
    ans *= a[i]
if ans > 10 ** 18:
    ans = '-1'
print(ans)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = 1
if 0 in a:
    print(0)
    exit()
for i in range(n):
    ans *= a[i]
    if ans > 10 ** 18:
        print(-1)
        exit()
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ans = 1
for i in range(n):
    
    ans *= a[i]
    if ans == 0:
        break
if ans > 10 ** 18:
    ans = '-1'
print(ans)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = 1
if 0 in a:
    print(0)
    exit()
for i in range(n):
    ans *= a[i]
    if ans > 10 ** 18:
        print(-1)
        exit()
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ans = 1
for i in range(n):
    ans *= a[i]
    if ans == 0:
        break
if ans > 10 ** 18:
    ans = -1
print(ans)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = 1
if 0 in a:
    print(0)
    exit()
for i in range(n):
    ans *= a[i]
    if ans > 10 ** 18:
        print(-1)
        exit()
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ans = 1
for i in range(n):
    ans *= a[i]
if ans > 10 ** 18:
    ans = -1
print(ans)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = 1
if 0 in a:
    print(0)
    exit()
for i in range(n):
    ans *= a[i]
    if ans > 10 ** 18:
        print(-1)
        exit()
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
x = int(input())

for i in range(-1000, 1000):
    for j in range(-1000, 1000):
        if math.pow(a, 5) == x + math.pow(b, 5):
            print(a, b)
            exit()

Fixed submission:
import math
x = int(input())

for a in range(-1000, 1000):
    for b in range(-1000, 1000):
        if math.pow(a, 5) == x + math.pow(b, 5):
            print(a, b)
            exit()
Buggy python submission (verdict: Time Limit Exceeded):
import math

k = int(input())
ans = 0
for a in range(1, k + 1):
    for b in range(1, k + 1):
        for c in range(1, k + 1):
            ans += math.gcd(math.gcd(a, b), c)

print(ans)


Fixed submission:
from math import gcd

K = int(input())
ans = 0
for i in range(1, K + 1):
    ans += i
for i in range(1, K + 1):
    for j in range(i + 1, K + 1):
        ans += gcd(i, j) * 6

for i in range(1, K - 1):
    for j in range(i + 1, K):
        for k in range(j + 1, K + 1):
            ans += gcd(gcd(i, j), k) * 6

print(ans)

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

k = int(input())
ans = 0
for a in range(1, k + 1):
    for b in range(1, k + 1):
        for c in range(1, k + 1):
            ans1 = math.gcd(a, b)
            ans += math.gcd(ans1, c)

print(ans)


Fixed submission:
from math import gcd

K = int(input())
ans = 0
for i in range(1, K + 1):
    ans += i
for i in range(1, K + 1):
    for j in range(i + 1, K + 1):
        ans += gcd(i, j) * 6

for i in range(1, K - 1):
    for j in range(i + 1, K):
        for k in range(j + 1, K + 1):
            ans += gcd(gcd(i, j), k) * 6

print(ans)

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

K = int(input())
ans = 0
for a in range(1, K + 1):
    for b in range(1, K + 1):
        for c in range(1, K + 1):
            ans1 = math.gcd(a, b)
            ans2 = math.gcd(ans1, c)
            ans += ans2

print(ans)


Fixed submission:
from math import gcd

K = int(input())
ans = 0
for i in range(1, K + 1):
    ans += i
for i in range(1, K + 1):
    for j in range(i + 1, K + 1):
        ans += gcd(i, j) * 6

for i in range(1, K - 1):
    for j in range(i + 1, K):
        for k in range(j + 1, K + 1):
            ans += gcd(gcd(i, j), k) * 6

print(ans)
Buggy python submission (verdict: Runtime Error):
l = int(input())
print((l/3)^3)

Fixed submission:
l = int(input())
print(l/3*l/3*l/3)
Buggy python submission (verdict: Runtime Error):
n, r = map(int, input())
if n >= 10:
    print(r)
else:
    print(r + 100 * (10 - n))


Fixed submission:
n, r = map(int, input().split())
if n >= 10:
    print(r)
else:
    print(r + 100 * (10 - n))
Buggy python submission (verdict: Runtime Error):
n = int(input())
x = list(map(int, input().split()))
x.sort()
sigmaList = list()
for p in range(x[0], x[n - 1]):
    sigma = 0
    for i in range(n):
        sigma += (x[i] - p) ** 2
    sigmaList.append(sigma)

print(min(sigmaList))


Fixed submission:
n = int(input())
x = list(map(int, input().split()))
x.sort()
sigmaList = list()
for p in range(x[0], x[n - 1] + 1):
    sigma = 0
    for i in range(n):
        sigma += (x[i] - p) ** 2
    sigmaList.append(sigma)
print(min(sigmaList))

Buggy python submission (verdict: Runtime Error):
n = int(input())
x = list(map(int, input().split()))
x.sort()
sigmaList = list()
for p in range(x[0], x[n]):
    sigma = 0
    for i in range(n):
        sigma += (x[i] - p) ** 2
    sigmaList.append(sigma)

print(min(sigmaList))


Fixed submission:
n = int(input())
x = list(map(int, input().split()))
x.sort()
sigmaList = list()
for p in range(x[0], x[n - 1] + 1):
    sigma = 0
    for i in range(n):
        sigma += (x[i] - p) ** 2
    sigmaList.append(sigma)
print(min(sigmaList))

Buggy python submission (verdict: Runtime Error):
n = int(input())
x = list(map(int, input().split()))
x.sort()
sigmaList = list()
for p in range(x[0], x[n - 1]):
    sigma = 0
    for i in range(n):
        sigma += (x[i] - p) ** 2
    sigmaList.append(sigma)

print(min(sigmaList))


Fixed submission:
n = int(input())
x = list(map(int, input().split()))
x.sort()
sigmaList = list()
for p in range(x[0], x[n - 1] + 1):
    sigma = 0
    for i in range(n):
        sigma += (x[i] - p) ** 2
    sigmaList.append(sigma)
print(min(sigmaList))

Buggy python submission (verdict: Runtime Error):
n = int(input())
x = list(map(int, input().split()))
x.sort()
sigmaList = list()
for p in range(x[0], x[n - 1]):
    sigma = 0
    for i in range(n):
        sigma += (x[i] - p) ** 2
    sigmaList.append(sigma)

print(min(sigmaList))


Fixed submission:
n = int(input())
x = list(map(int, input().split()))
x.sort()
sigmaList = list()
for p in range(x[0], x[n - 1] + 1):
    sigma = 0
    for i in range(n):
        sigma += (x[i] - p) ** 2
    sigmaList.append(sigma)
print(min(sigmaList))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    if a % 2 == 0:
        if a % 3 == 0 or a % 5 == 0:
            print("APPROVED")
    else:
        print("DENIED")



Fixed submission:
n = int(input())
a = list(map(int, input().split()))
flg = True
for i in range(n):
    if a[i] % 2 == 0:
        if a[i] % 3 == 0 or a[i] % 5 == 0:
            pass
        else:
            flg = False
            break

if flg:
    print("APPROVED")
else:
    print("DENIED")
Buggy python submission (verdict: Runtime Error):
a,b = map(int, input().split())a, b = map(int, input().split())
if a[0] < b[0]:
    print(a)
else:
    print(b)

Fixed submission:
a, b = input().split()
if int(a[0]) < int(b[0]):
    print(a * int(b))
else:
    print(b * int(a))
Buggy python submission (verdict: Runtime Error):
c = input()
s = "abcdefghijklmnopqrstuvwxyz"
flg = True
for i in range(len(s) + 1):
    if c == s[i] and c != "z":
        print(s[i + 1])
        flg = False
    elif c == "z":
        print("a")
        flg = False


Fixed submission:
c = input()
s = "abcdefghijklmnopqrstuvwxyz"
flg = True
for i in range(len(s) + 1):
    if c == s[i] and c != "z":
        print(s[i + 1])
        break
    elif c == "z":
        print("a")
        break

Buggy python submission (verdict: Runtime Error):
c = input()
s = 'abcdefghijklmnopqrstuvwxyz'
flg = True
while flg:
    if c == s[i] and c != 'z':
        print(s[i + 1])
        flg = False
    elif c == 'z':
        print('a')
        flg = False

Fixed submission:
c = input()
s = "abcdefghijklmnopqrstuvwxyz"
flg = True
for i in range(len(s) + 1):
    if c == s[i] and c != "z":
        print(s[i + 1])
        break
    elif c == "z":
        print("a")
        break

Buggy python submission (verdict: Runtime Error):
c = input()
s = 'abcdefghijklmnopqrstuvwxyz'
flg = True
while flg:
    if c == s[i] and c != 'z':
        print(s[i + 1])
        flg = False
    elif c == 'z':
        print('a')
        flg = False

Fixed submission:
c = input()
s = "abcdefghijklmnopqrstuvwxyz"
flg = True
for i in range(len(s) + 1):
    if c == s[i] and c != "z":
        print(s[i + 1])
        break
    elif c == "z":
        print("a")
        break
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [str(input()) for _ in range(n)]
ans = 0
for i in range(n):
    s[i] = "".join(sorted(s[i]))
    # print(s[i])


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

print(ans)


Fixed submission:
n = int(input())
s = [input() for _ in range(n)]
for i in range(n):
  s[i] = ''.join(sorted(s[i]))
t = {}
for i in range(n):
  if s[i] in t:
    t[s[i]] += 1
  else:
    t[s[i]] = 1
print(sum(t[k] * (t[k] -1) // 2 for k in t))

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = [str(input()) for _ in range(n)]
t = []
ans = 0
for i in range(n):
    s[i] = sorted(s[i])

t = set(s)
ans = len(s) - len(t)


print(ans)


Fixed submission:
n = int(input())
s = [input() for _ in range(n)]
for i in range(n):
  s[i] = ''.join(sorted(s[i]))
t = {}
for i in range(n):
  if s[i] in t:
    t[s[i]] += 1
  else:
    t[s[i]] = 1
print(sum(t[k] * (t[k] -1) // 2 for k in t))

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = [str(input()) for _ in range(n)]
t = []
ans = 0
for i in range(n):
    s[i] = sorted(s[i])

t = set(s)
ans = len(s) - len(t)


print(ans)


Fixed submission:
n = int(input())
s = [input() for _ in range(n)]
for i in range(n):
  s[i] = ''.join(sorted(s[i]))
t = {}
for i in range(n):
  if s[i] in t:
    t[s[i]] += 1
  else:
    t[s[i]] = 1
print(sum(t[k] * (t[k] -1) // 2 for k in t))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [str(input()) for _ in range(n)]
ans = 0
for i in range(n):
    s[i] = sorted(s[i])
 
 
for i in range(n):
    for j in range(i,):
        if s[i] == s[j]:
            ans += 1
 
print(ans)

Fixed submission:
n = int(input())
s = [input() for _ in range(n)]
for i in range(n):
  s[i] = ''.join(sorted(s[i]))
t = {}
for i in range(n):
  if s[i] in t:
    t[s[i]] += 1
  else:
    t[s[i]] = 1
print(sum(t[k] * (t[k] -1) // 2 for k in t))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [str(input()) for _ in range(n)]
ans = 0
for i in range(n):
    s[i] = sorted(s[i])


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

print(ans)


Fixed submission:
n = int(input())
s = [input() for _ in range(n)]
for i in range(n):
  s[i] = ''.join(sorted(s[i]))
t = {}
for i in range(n):
  if s[i] in t:
    t[s[i]] += 1
  else:
    t[s[i]] = 1
print(sum(t[k] * (t[k] -1) // 2 for k in t))
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for i in range(A + 1):
    for j in range(B + 1):
        for k in range(C + 1):
            if i * 500 + j * 100 + k * 50 == X:
                count += 1

print(count) 2



Fixed submission:
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for i in range(A + 1):
    for j in range(B + 1):
        for k in range(C + 1):
            if i * 500 + j * 100 + k * 50 == X:
                count += 1

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
def quiz(N,K,Q):
    if K>Q:
        for ans in range(N):
            print('Yes')
    else:
        an=[]
        for qui in range(Q):
            an.append(int(input()))
        po=(Q+1)-K
        for su in range(1,N+1):
            if an.count(su) >=po:
                print('Yes')
            else:
                print('No')
N,K,Q=map(int,input().split())
quiz(N,K,Q)

Fixed submission:
n, k, q = map(int, input().split())
b = [k - q] * n

for i in range(q):
    ai = int(input())
    b[ai - 1] += 1

for j in range(n):
    if b[j] > 0:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
L,R=map(int,input().split())
ans=list(range(L,R+1))
for i in range(M-1):
    H,I=map(int,input().split())
    ans=list(filter(lambda key:H<=key<=I,ans))
    if ans==[]:
        break
print(len(ans))

Fixed submission:
N,M=map(int,input().split())
L,R=map(int,input().split())
for i in range(M-1):
    H,I=map(int,input().split())
    if H>L:
        L=H
    if R>I:
        R=I
    if R<L:
        break
if R<L:
    print(0)
else:
    ans=list(range(L,R+1))
    print(len(ans))
Buggy python submission (verdict: Runtime Error):
A,B,C=map(int,input().split())
if A == C:
  print('Yes')
else:
  print('No')

Fixed submission:
A,B,C=input()
if int(A)==int(C):
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Time Limit Exceeded):
import sys

Z = 998244353


def input():
    return sys.stdin.readline().rstrip('\n')


def calc(N, K, LR):
    c = []
    for (l, r) in LR:
        for i in range(l, r + 1):
            c += [i]
    d = [0] * N
    d[0] = 1
    for i in range(N):
        if d[i] == 0:
            continue
        for e in c:
            if i + e < N:
                d[i + e] = (d[i + e] + d[i]) % Z
    return d[N - 1]


(N, K) = tuple([int(s) for s in input().split()])
LR = [tuple([int(s) for s in input().split()]) for _ in range(K)]
print(calc(N, K, LR))

Fixed submission:
import sys

Z = 998244353


def input():
    return sys.stdin.readline().rstrip('\n')


def calc(N, K, LR):
    f = [0] * N
    a = [0] * N
    f[0] = 1
    a[0] = -1
    for i in range(N - 1):
        for (l, r) in LR:
            if i + l - 1 < N:
                a[i + l - 1] = a[i + l - 1] + f[i]
            if i + r < N:
                a[i + r] = a[i + r] - f[i]
        f[i + 1] = (a[i] + f[i]) % Z
    return f[N - 1]


(N, K) = tuple([int(s) for s in input().split()])
LR = [tuple([int(s) for s in input().split()]) for _ in range(K)]
print(calc(N, K, LR))
Buggy python submission (verdict: Runtime Error):
s = input()
if s == 'RRR':
  return 3
elif s == 'RRS' or s == 'SRR':
  return 2
elif s == 'SSS':
  return 0
else:
  return 1

Fixed submission:
s = input()
if s == 'RRR':
  print(3)
elif s == 'RRS' or s == 'SRR':
  print(2)
elif s == 'SSS':
  print(0)
else:
  print(1)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input():
    return sys.stdin.readline().rstrip('\n')
    

def calc(N, M, K, A, B):
    na = 0
    A = [0] + A
    for i in range(1, len(A)):
        A[i] += A[i - 1]
        if A[i] > K:
            break
        na += 1
    nb = 0
    B = [0] + B
    for i in range(1, len(B)):
        B[i] += B[i - 1]
        if B[i] > K:
            break
        nb += 1
    i = 0
    while True:
        for j in range(max(na - i, 0), na + 1):
            if na + nb - i - j >= 0 and na + nb - i - j <= nb and A[j] + B[na + nb - i - j] <= K:
                return na + nb - i
        i += 1


(N, M, K) = tuple([int(s) for s in input().split()])
A = [int(s) for s in input().split()]
B = [int(s) for s in input().split()]
print(calc(N,M,K,A,B))

Fixed submission:
import sys
def input():
    return sys.stdin.readline().rstrip('\n')
    

def calc(N, M, K, A, B):
    na = 0
    A = [0] + A
    for i in range(1, len(A)):
        A[i] += A[i - 1]
        if A[i] > K:
            break
        na += 1
    nb = 0
    B = [0] + B
    for i in range(1, len(B)):
        B[i] += B[i - 1]
        if B[i] > K:
            break
        nb += 1
    ans = nb
    t = nb
    for i in range(1, na + 1):
        for j in range(t, -1, -1):
            if A[i] + B[j] <= K:
                ans = max(ans, i + j)
                t = j
                break
    return ans


(N, M, K) = tuple([int(s) for s in input().split()])
A = [int(s) for s in input().split()]
B = [int(s) for s in input().split()]
print(calc(N,M,K,A,B))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input():
    return sys.stdin.readline().rstrip('\n')

def calc(N, S):
    A = {}
    for s in S.split():
        x = int(s)
        if x in A:
            A[x] = 0
        else:
            A[x] = 1
        for a in A:
            if a == x:
                continue
            if x % a == 0:
                A[x] = 0
            if a % x == 0:
                A[a] = 0
    n = 0
    for a in A:
        n += A[a]
    return n
    

N = int(input())
S = input()
print(calc(N, S))

Fixed submission:
import sys
def input():
    return sys.stdin.readline().rstrip('\n')
    

def calc(N, A):
    A.sort()
    M = A[N - 1] + 1
    b = [False for _ in range(M)]
    tmp = -1
    d = set()
    for a in A:
        if a == tmp:
            d.add(a)
            continue
        for i in range(a * 2, M, a):
            b[i] = True
        tmp = a
    n = 0
    for a in A:
        if not a in d:
            n += (0 if b[a] else 1)
    return n

N = int(input())
A = [int(s) for s in input().split()]
print(calc(N, A))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input():
    return sys.stdin.readline().rstrip('\n')


def calc(N, A):
    result = 0
    for i in range(N):
        a = A[i]
        for j in range(i + 1, N):
            if a == j - i - A[j]:
                result += 1
    return result
    

N = int(input())
A = [int(s) for s in input().split()]
print(calc(N, A))

Fixed submission:
import math
import sys
def input():
    return sys.stdin.readline().rstrip('\n')


def calc(N, A):
    result = 0
    diff = [i - A[i] for i in range(N)]
    d1 = {}
    for x in diff:
        d1[x] = (d1[x] if x in d1 else 0) + 1 
    plus = [i + A[i] for i in range(N)]
    d2 = {}
    for x in plus:
        d2[x] = (d2[x] if x in d2 else 0) + 1
    for x in d1:
        y = d2[x] if x in d2 else 0
        result += d1[x] * y
    return result
    

N = int(input())
A = [int(s) for s in input().split()]
print(calc(N, A))