Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

M = 10**9+7
N = int(input())
A = list(map(int,input().split()))

maxA = max(A)
K = len(str(bin(maxA)))-2
ans = 0
for k in range(K):
    N1 = 0
    bk = 1<<k
    for i in range(0,N):
#        N1 += ( (A[i] >> k) & 1)
        N1 += (A[i] & bk)
    N1 //= bk
    N0 = N-N1
    ans += (((1<<k)%M) *N0 *N1) % M

ans %= M    
print(int(ans))

### FIXED CODE ###

M = 10**9+7
N = int(input())
A = list(map(int,input().split()))

ans = 0
for k in range(61):
    N1 = 0
    N1 = sum([1 for a in A if ( (a >> k) & 1)])
    ans += (((1<<k)) *(N-N1) *N1)
    ans %= M    

print(ans)
### BUGGY CODE ###

C = -(10**9 + 7)


def main():
    from collections import defaultdict
    N = int(input())
    K = N//2
    A = [int(i) for i in input().split()]
    dp = defaultdict(lambda: C)
    for i in range(N+1):
        dp[(i, 0)] = 0
        if i != 0:
            dp[(i, 1)] = max(dp[(i-1, 1)], A[i-1])
    for i in range(2, N+1):
        for j in range(max(i//2 - 1, 0), i+1//2 + 1):
            if dp[(i-1, j)] == C and dp[(i-2, j-1)] == C \
                    and (i < 3 or dp[(i-3, j-1)] == C):
                continue
            else:
                dp[(i, j)] = max(dp[(i, j)], dp[(i-1, j)],
                                 dp[(i-2, j-1)] + A[i-1],
                                 dp[(i-3, j-1)] + A[i-1])
    print(dp[(N, K)])
    # print(*dp, sep="\n")


if __name__ == '__main__':
    main()


### FIXED CODE ###

C = -(10**15 + 7)


def main():
    from collections import defaultdict
    N = int(input())
    K = N//2
    A = [int(i) for i in input().split()]
    dp = defaultdict(lambda: C)
    for i in range(N+1):
        dp[i, 0] = 0
        if i != 0:
            dp[(i, 1)] = max(dp[i-1, 1], A[i-1])
    for i in range(2, N+1):
        for j in range(i//2-1, (i+1)//2 + 1):
            if j < 0:
                continue
            # A_i(1-index)でj個選ばなければいけない
            dp[i, j] = max(dp[i, j], dp[i-2, j-1] + A[i-1],
                           dp[i-3, j-1] + A[i-1], dp[i-4, j-1] + A[i-1])
    print(max(dp[N, K], dp[N-1, K], dp[N-2, K]))
    # for i in range(N+1):
    #     for j in range(K+1):
    #         print("{:>4}".format(dp[i, j] if dp[i, j] != C else "C"),
    #               end=" " if j != K else "\n")


if __name__ == '__main__':
    main()
### BUGGY CODE ###

import sys
input = sys.stdin.readline

from fractions import gcd


def lcd(x, y):
    g = gcd(x, y)
    return x * y // g


n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7

a.sort()

l = 1
for e in a:
    l = lcd(l, e)

ans = 0
for e in a:
    ans += l // e
    ans %= mod

print(ans)



### FIXED CODE ###

from fractions import gcd


def lcm(a, b):
    return a * b // gcd(a, b)


n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7

l = 1
for e in a:
    l = lcm(l, e)

l %= mod

ans = 0
for e in a:
    ans += l * pow(e, mod - 2, mod)
    ans %= mod

print(ans)
### BUGGY CODE ###

from itertools import accumulate
N, M = map(int, input().split())
 
AB = []
 
for i in range(N):
    a, b = map(int, input().split())
    AB.append([a, b])

AB.sort(key=lambda x: x[0])
 
ans = 0
cnt = 0
whole = []
 
for ab in AB:
    for b in range(ab[1]):
        whole.append(ab[0])

ans = list(accumulate(whole))

print(ans[M-1])

### FIXED CODE ###

N, M = map(int, input().split())

AB = []

for i in range(N):
    a, b = map(int, input().split())
    AB.append([a, b])

AB.sort()

ans = 0
cnt = 0

for ab in AB:
    for b in range(ab[1]):
        ans += ab[0]
        cnt += 1
        if cnt==M:
            break
    if cnt==M:
        break

print(ans)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in a:
    if i == 0 and max(a):
        continue
    elif i < max(a):
        ans += 1

print(ans)

### FIXED CODE ###

from sys import stdin
readline = stdin.readline
n = int(readline())
a = list(map(int, readline().split()))
x = 0
ans = 0
for i in a:
    if x > i:
        ans += (x-i)
    else:
        x = i
print(ans)
### BUGGY CODE ###

import math

def gcd3(a, b, c):
    temp = math.gcd(a, b)
    return math.gcd(temp, c)

n = int(input())
s = sum([gcd3(a, b, c) for a in range(1, n + 1) for b in range(1, n + 1) for c in range(1, n + 1)])
print(s)


### FIXED CODE ###

import math

def gcd3(a, b, c):
    temp = math.gcd(a, b)
    return math.gcd(temp, c)

n = int(input())
s = sum([gcd3(a, b, c) for a in range(1, n + 1) for b in range(1, n + 1) for c in range(1, n + 1)])
print(s)
### BUGGY CODE ###

import itertools
n,k=map(int,input().split())
l=list(map(int,input().split()))
if k>42:
    l=[n]*n
    print(*l)
else:
    for _ in range(k):
        countl=[0]*(n+1)
        for i in range(n):
            countl[max(1,i+1-l[i])]+=1
            if i+2+l[i]<=n:
                countl[i+2+l[i]]-=1
            
        l=list(itertools.accumulate(countl))
        l.remove(l[0])
    print(*l)

### FIXED CODE ###

import itertools
n,k=map(int,input().split())
l=list(map(int,input().split()))
if k>42:
    l=[n]*n
    print(*l)
else:
    for _ in range(k):
        countl=[0]*(n+1)
        for i in range(n):
            countl[max(1,i+1-l[i])]+=1
            if i+2+l[i]<=n:
                countl[i+2+l[i]]-=1
            
        l=list(itertools.accumulate(countl))
        l.remove(l[0])
    print(*l)
### BUGGY CODE ###

n = int(input())
li = []

for _ in range(n):
    s = input()
    count = 0
    while True:
        if count + 1 >= len(s):
            break
        if s[count] == '(' and s[count+1] == ')':
            s = s[:count] + s[count+2:]
            count = max(0, count-1)
        else:
            count += 1
    li.append(s)

li2 = []
for i in li:
    count = 0
    for j in range(len(i)):
        if i[j] == ')':
            count += 1
        else:
            break
    li2.append((count, len(i) - count))

li3 = []
li4 = []

for i in li2:
    if i[0] <= i[1]:
        li3.append(i)
    else:
        li4.append(i)

li3.sort()
li4.sort(key = lambda x: x[1], reverse = True)

s2 = ''
for l,r in li3:
    s2 += ')' * l + '(' * r
for l,r in li4:
    s2 += ')' * l + '(' * r

count = 0
while True:
    if count + 1 >= len(s2):
        break
    if s2[count] == '(' and s2[count+1] == ')':
        s2 = s2[:count] + s2[count+2:]
        count = max(0, count-1)
    else:
        count += 1

if s2 == '':
    print('Yes')
else:
    print('No')


### FIXED CODE ###

n = int(input())
li = []

for _ in range(n):
    s = input()
    count = 0
    while True:
        if count + 1 >= len(s):
            break
        if s[count] == '(' and s[count+1] == ')':
            s = s[:count] + s[count+2:]
            count = max(0, count-1)
        else:
            count += 1
    li.append(s)

li2 = []
for i in li:
    count = 0
    for j in range(len(i)):
        if i[j] == ')':
            count += 1
        else:
            break
    li2.append((count, len(i) - count))

li3 = []
li4 = []

for i in li2:
    if i[0] <= i[1]:
        li3.append(i)
    else:
        li4.append(i)

li3.sort()
li4.sort(key = lambda x: x[1], reverse = True)

now = [0,0]

for l,r in li3:
    if l == 0 and r == 0:
        pass
    elif l == 0:
        now[1] += r
    else:
        now[1] -= l
        if now[1] < 0:
            print('No')
            exit()
        now[1] += r

for l,r in li4:
    if l == 0 and r == 0:
        pass
    elif r == 0:
        now[1] -= l
        if now[1] < 0:
            print('No')
            exit()
    else:
        now[1] -= l
        if now[1] < 0:
            print('No')
            exit()
        now[1] += r

if now[0] == 0 and now[1] == 0:
    print('Yes')
else:
    print('No')
### BUGGY CODE ###

H, W, D = map(int, input().split())
X, Y = [-1] * H * W, [-1] * H * W

for h in range(H):
    A = list(map(int, input().split()))
    for w in range(W):
        X[A[w] - 1], Y[A[w] - 1] = h, w

Q = int(input())
for _ in range(Q):
    L, R = map(int, input().split())
    ans = 0
    while L != R:
        ans += abs(X[L - 1] - X[L + D - 1]) + abs(Y[L - 1] - Y[L + D - 1])
        L += D
    print(ans)


### FIXED CODE ###

H, W, D = map(int, input().split())
X, Y, ans = [-1] * H * W, [-1] * H * W, [0] * H * W

for h in range(H):
    A = list(map(int, input().split()))
    for w in range(W):
        X[A[w] - 1], Y[A[w] - 1] = h, w

for d in range(D):
    while d + D < H * W:
        ans[d + D] = ans[d] + abs(X[d] - X[d + D]) + abs(Y[d] - Y[d + D])
        d += D

Q = int(input())
for _ in range(Q):
    L, R = map(int, input().split())
    print(ans[R - 1] - ans[L - 1])
### BUGGY CODE ###

n = int(input())

num_list = [i+1 for i in range(n)]

print(sum(num_list) - n)

### FIXED CODE ###

n = int(input())

print(n*(n-1) // 2)
### BUGGY CODE ###

import decimal
n = int(input())
a=[input() for i in range(n)]
biga=[]
for i in range(n):
    num = decimal.Decimal(a[i])
    biga.append(int(num*10**9))
def fact25(n):
    cnt2=0
    cnt5=0
    while n%2==0:
        n//=2
        cnt2+=1
    while n%5==0:
        n//=5
        cnt5+=1
    return cnt2,cnt5

arr = [[0 for _ in range(20)] for _ in range(20)]
p25 = []
for i in range(n):
    cnt2,cnt5=fact25(biga[i])
    p25.append([cnt2,cnt5])
    cnt2=min(19,cnt2)
    cnt5=min(19,cnt5)
    arr[cnt2][cnt5]+=1
ans=0
for i in range(n):
    cnt2,cnt5=p25[i]
    n2=18-cnt2
    n5=18-cnt5
    cnt2=min(19,cnt2)
    cnt5=min(19,cnt5)
    arr[cnt2][cnt5]-=1
    for j in range(20): # 2
        for k in range(20): # 5
            if j>=n2 and k>=n5:
                ans+=arr[j][k]
    arr[cnt2][cnt5]+=1

print(ans//2)

### FIXED CODE ###

import decimal
n = int(input())
a=[input() for i in range(n)]
biga=[]
for i in range(n):
    num = decimal.Decimal(a[i])
    biga.append(int(num*10**9))
def fact25(n):
    cnt2=0
    cnt5=0
    while n%2==0:
        n//=2
        cnt2+=1
    while n%5==0:
        n//=5
        cnt5+=1
    return cnt2,cnt5

arr = [[0 for _ in range(20)] for _ in range(20)]
p25 = []
for i in range(n):
    cnt2,cnt5=fact25(biga[i])
    p25.append([cnt2,cnt5])
    cnt2=min(19,cnt2)
    cnt5=min(19,cnt5)
    arr[cnt2][cnt5]+=1

ans=0
for i in range(20): # 2
    for j in range(20): # 5
        if arr[i][j]==0:
            continue
        for k in range(20): # 2
            for l in range(20): # 5
                if i+k>=18 and j+l>=18:
                    if i==k and j==l:
                        ans+= (arr[i][j]-1)*arr[k][l]
                    else:
                        ans+= arr[i][j]*arr[k][l]

print(ans//2)
### BUGGY CODE ###

n=int(input())

A=list(map(int,input().split()))
ans=int(1)

for i in range(n):
    ans*=A[i]
if ans>1e18:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

n=int(input())

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

ans=int(1)

for i in range(n):
    ans*=A[i]
    if ans>1e18:
        print(-1)
        exit()
print(ans)
### BUGGY CODE ###

N = int(input())
men = []
hCeil = 0
for _ in range(N):
    h,p = map(int,input().split())
    men.append((h+p,h,p))
    hCeil = max(hCeil,h)
men.sort()
hCeil += 1
"""
dp[i][j][0] -> i人目までみる&j人が積むときの最小枚数
dp[i][j][1] -> 積んだかどうかのフラグ
"""
dp = [[(hCeil,0) for i in range(N+1)] for _ in range(N+1)]
for i in range(N+1):
    dp[i][0] = (0,1)
for i in range(1,N+1):
    h,p = men[i-1][1],men[i-1][2]
    for j in range(1,i+1):
        if dp[i-1][j-1][0]<=h:
            nxP = min(dp[i-1][j][0],dp[i-1][j-1][0]+p)
            dp[i][j] = (nxP,1)
        else:
            dp[i][j] = dp[i-1][j]

for j in range(N,-1,-1):
    if dp[-1][j][1] != 0:
        print(j)
        break


### FIXED CODE ###

N = int(input())
men = []
for _ in range(N):
    H,P = map(int,input().split())
    men.append((H,P,H+P))
men.sort(key=lambda x: x[2])

maxH = max(men)[0]
inf = maxH+1
#dp[i][j] -> i人目までみたとき、j人が座布団を積む場合の最小枚数
dp = [[-1]*(N+1) for _ in range(N+1)]
dp[0][0] = 0
for i in range(1,N+1):
    h,p,a = men[i-1]
    for j in range(1,N+1):
        if 0 <= dp[i-1][j-1] <= h:
            if dp[i-1][j] == -1:
                dp[i][j] = dp[i-1][j-1]+p
            else:
                dp[i][j] = min(dp[i-1][j],dp[i-1][j-1]+p)
        else:
            dp[i][j] = dp[i-1][j]

for j in range(N,-1,-1):
    if dp[-1][j] != -1:
        print(j)
        break
### BUGGY CODE ###

MOD = 10**9+7
from math import factorial    
def comb(a, b):
    ret = factorial(a) // (factorial(a-b)*factorial(b))
    return ret % MOD

if __name__ == '__main__':
    N,M = map(int, input().split())
    ans = 1
    
    #  素因数分解
    i=2
    nokori = M
    while i*i <= nokori:
        if nokori%i==0:
            cnt = 0
            while nokori%i==0:
                cnt += 1
                nokori //= i
            ans *= comb(N+cnt-1, N-1)
            ans %= MOD
        i += 1
            
    if nokori != 1:
        ans *= comb(N+1-1, N-1)
        ans %= MOD
        
    print(ans)


### FIXED CODE ###

MOD = 10**9+7

def modpow(a:int, p:int)->int:
    # return a**p (mod MOD)
    if p==0: return 1
    if p%2==0:
        half_p = p//2
        half = modpow(a, half_p)
        return half*half % MOD
    else:
        return a * modpow(a, p-1) % MOD
    
def comb(a:int, b:int):
    if b > a-b: return comb(a, a-b)
    mul = 1
    div = 1
    for i in range(b):
        mul *= a-i
        div *= i+1
        mul %= MOD
        div %= MOD
        
    ret = mul * modpow(div, MOD-2) % MOD
    return ret

if __name__ == '__main__':
    N,M = map(int, input().split())
    ans = 1
    
    #  素因数分解
    i=2
    nokori = M
    while i*i <= nokori:
        if nokori%i==0:
            cnt = 0
            while nokori%i==0:
                cnt += 1
                nokori //= i
            ans *= comb(N+cnt-1, N-1)
            ans %= MOD
        i += 1
            
    if nokori != 1:
        ans *= comb(N+1-1, N-1)
        ans %= MOD
        
    print(ans)
### BUGGY CODE ###

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

ans = 1

for i in range(N):
  if any(j == 0 for j in A) == True:
    print(0)
    break
  ans *= A[i]
  i += 1
  if ans > 10**18:
    print('-1')
    break
  if i == N:
    print(ans)

### FIXED CODE ###

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

ans = 1

if 0 in A:
  ans = 0
else:
  for i in range(N):
    ans *= A[i]
    i += 1
    if ans > 10**18:
      ans = -1
      break

print(ans)
### BUGGY CODE ###

if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))

    t = set()
    dup = [x for x in A if x in t or t.add(x)]
    no_dup = list(set(dup))
    square_list = []
    for i in no_dup:
        if 3 <= dup.count(i):
            square_list.append(i)

    no_dup.sort(reverse=True)
    square_list.sort(reverse=True)
    if len(no_dup) == 0:
        print(0)
    else:
        if len(square_list) == 0:
            square_area = 0
        else:
            square_area = square_list[0] * square_list[0]
        if len(no_dup) == 1:
            rectan_area = 0
        else:
            rectan_area = no_dup[0] * no_dup[1]
        if square_area < rectan_area:
            print(rectan_area)
        else:
            print(square_area)


### FIXED CODE ###

if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))

    A.sort(reverse=True)

    v = []
    while len(A) > 1:
        if len(v) == 2:
            break

        if A[0] == A[1]:
            v.append(A[0])
            A.pop(0)
            A.pop(0)
        else:
            A.pop(0)

    if len(v) == 1 or len(v) == 0:
        print(0)
    else:
        print(v[0] * v[1])
### BUGGY CODE ###

def main():
    N,Y = list(map(int,input().split()))

    flag = False

    for i in range(N+1):
        for j in range(N+1):
            for k in range(N+1):
                if(i+j+k == N and 10000 * i + 5000 * j + 1000 * k == Y):
                    print(i,j,k)
                    flag = True
                    break
            if(flag):
                break
        if(flag):
            break
    if(not flag):
        print(-1,-1,-1)

if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    N,Y = list(map(int,input().split()))

    flag = False

    loop_10000 = Y // 10000
    loop_5000 = Y // 5000
    loop_1000 = Y // 1000

    for i in range(loop_10000+1):
        for j in range(loop_5000+1):
            k = N - i - j
            if(k >= 0 and i+j+k == N and 10000 * i + 5000 * j + 1000 * k == Y):
                print(i,j,k)
                flag = True
                break
            #for k in range(loop_1000+1):
            #    if(i+j+k == N and 10000 * i + 5000 * j + 1000 * k == Y):
            #        print(i,j,k)
            #        flag = True
            #        break
            #if(flag):
            #    break
        if(flag):
            break
    if(not flag):
        print(-1,-1,-1)

if __name__ == "__main__":
    main()
### BUGGY CODE ###

import numpy as np
n, k = map(int, input().split())
h = np.array([int(input()) for _ in range(n)],dtype=int)
h.sort()
print(min([np.max(h[x:x+k]) - np.min(h[x:x+k]) for x in range(n-k+1)]))


### FIXED CODE ###

import numpy as np
n, k = map(int, input().split())
h = np.array([int(input()) for _ in range(n)],dtype=int)
h.sort()
print(min([h[x+k-1] - h[x] for x in range(n-k+1)]))
### BUGGY CODE ###

import random
 
n = int(input())
a = [int(i) for i in input().split()]
 
rc = 0
while rc != 1000:
	c = 0
	for i in range(len(a)-1):
		if a[i] != int(bin(a[i-1]^a[i+1]),0):
			c=1
			random.shuffle(a)
			rc+=1
			break
	if c==0:
		if a[-1] != int(bin(a[0]^a[-2]),0):
			random.shuffle(a)
			rc+=1
		else:
			print("Yes")
			exit()
print("No")

### FIXED CODE ###

n = int(input())
a = [int(i) for i in input().split()]
sum = 0
for i in a:
	sum^=i
if sum == 0:
	print("Yes")
else:
	print("No")
### BUGGY CODE ###

def double_accumulate(a):
    h = len(a)
    w = len(a[0])
    b = [[0]*(w+1) for i in range(h+1)]
    b[1][1] = a[0][0]
    for i in range(h):
        for j in range(w):
            b[i+1][j+1] = b[i+1][j]+b[i][j+1]-b[i][j]+a[i][j]
    return tuple(tuple(x) for x in b)


def double_sum(b,p,q):
    return b[q[0]+1][q[1]+1]-b[q[0]+1][p[1]]-b[p[0]][q[1]+1]+b[p[0]][p[1]]


n,k = map(int, input().split())

kk = k*2

black = [[0]*kk for i in range(kk)]
white = [[0]*kk for i in range(kk)]

for i in range(n):
    x,y,c = input().split()
    x = int(x)%kk
    y = int(y)%kk
    if c == 'B':
        black[x][y]+=1
    else:
        white[x][y]+=1

black = tuple(tuple(black[i%kk]*2) for i in range(kk*2))
white = tuple(tuple(white[i%kk]*2) for i in range(kk*2))

B = double_accumulate(black)
W = double_accumulate(white)

ans = 0
for i in range(kk):
    for j in range(kk):
        b = double_sum(B,[i,j],[i+k-1,j+k-1])\
            + double_sum(B,[i+k,j+k],[i+kk-1,j+kk-1])
        w = double_sum(W,[i,j+k],[i+k-1,j+kk-1])\
            + double_sum(W,[i+k,j],[i+kk-1,j+k-1])
        ans = max(ans,b+w)

print(ans)


### FIXED CODE ###

class Accumulate2D:
    def __init__(self, a):
        self.height = len(a)
        self.width = len(a[0])
        self.acc = self.accumulate(a)

    def accumulate(self,a):
        b = [[0]*(self.width+1) for i in range(self.height+1)]
        b[1][1] = a[0][0]
        for i in range(self.height):
            for j in range(self.width):
                b[i+1][j+1] = b[i+1][j]+b[i][j+1]-b[i][j]+a[i][j]
        return b

    def sum(self, p, q):
        y1,x1 = p
        y2,x2 = q
        b = self.acc
        if y1>y2 or x1>x2:
            return 0
        else:
            return b[y2+1][x2+1]-b[y2+1][x1]-b[y1][x2+1]+b[y1][x1]


n,k = map(int, input().split())

kk = k*2

z = [[0]*kk for i in range(kk)]

for i in range(n):
    x,y,c = input().split()
    x = int(x) % kk
    y = int(y) % kk
    if c=='W':
        x = (x+k)%kk
    z[x][y]+=1

z = Accumulate2D(z)

ans = 0
for i in range(k):
    for j in range(k):
        a = z.sum([0,0],[i-1,j-1])\
            + z.sum([i,j],[i+k-1,j+k-1])\
            + z.sum([0,j+k],[i-1,kk-1])\
            + z.sum([i+k,0],[kk-1,j-1])\
            + z.sum([i+k,j+k],[kk-1,kk-1])
        ans = max(ans,a,n-a)

print(ans)
### BUGGY CODE ###

n = int(input())
a = [i for i in map(int, input().split())]


def money(arr):
    now_x = 0
    total_score = 0

    for i in arr:
        total_score += abs(i-now_x)
        now_x = i

    total_score += abs(now_x)
    return total_score


for i in range(n):
    tmp = [i for i in a]

    tmp.pop(i)
    tmp.append(0)

    print(money(tmp))


### FIXED CODE ###

n = int(input())
a = [i for i in map(int, input().split())]
a.append(0)
a.insert(0, 0)


def money(arr):
    now_x = 0
    total_score = 0

    for i in arr:
        total_score += abs(i-now_x)
        now_x = i

    total_score += abs(now_x)
    return total_score


total = money(a)


for i in range(len(a)-2):
    now_point = a[i]
    break_point = a[i+1]
    next_point = a[i+2]

    break_distance = abs(next_point-now_point)
    normal_distance = abs(break_point-now_point) + \
        abs(next_point - break_point)

    if(break_distance == normal_distance):
        print(total)
    else:
        print(total - abs(break_distance-normal_distance))
### BUGGY CODE ###

N = int(input())
A = list(int(x) for x in input().split())
a = len(A)
sa = sorted(A)
su = 0
for i in range(a):
    for j in range(a):
        if i<j:
            su += A[i]*A[j]

print(su%(10**9+7))

### FIXED CODE ###

N = int(input())
A = list(int(x) for x in input().split())
B = [0]
a = len(A)
sa = sorted(A)
su = 0
p = 10**9+7

for i in range(a):
    B.append(B[i] + sa[i])

for j in range(a):
    su += sa[j]*B[j]

print(su%p)
### BUGGY CODE ###

def main():    
    import bisect
    n,q = map(int,input().split())
    l = [list(map(int,input().split())) for i in range(n)]
    l = sorted(l,key = lambda x: x[2])
    d = [int(input()) for i in range(q)]

    ans = [-1]*q
    skip = [-1]*q
    for s,t,x in l:
        le = bisect.bisect_left(d,s-x)
        ri = bisect.bisect_left(d,t-x)
        while le < ri:
            if skip[le] == -1:
                ans[le] = x
                skip[le] = ri
                le += 1
            else:
                le = skip[le]

    for i in ans:
        print(i)
if __name__ == "__main__":
    main()

### FIXED CODE ###

import bisect
n,q = map(int,input().split())
l = [list(map(int,input().split())) for i in range(n)]
l = sorted(l,key = lambda x: x[2])
d = [int(input()) for i in range(q)]

ans = [-1]*q
skip = [-1]*q
for s,t,x in l:
    le = bisect.bisect_left(d,s-x)
    ri = bisect.bisect_left(d,t-x)
    while le < ri:
        if skip[le] == -1:
            ans[le] = x
            skip[le] = ri
            le += 1
        else:
            le = skip[le]

for i in ans:
    print(i)
### BUGGY CODE ###

import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : map(int, stdin.readline().split())

def main():
  n = ni()
  a = list(na())
  sorta = sorted(a)
  res = []
  for aa in sorta:
    res.append(a.index(aa)+1)
  print(*res)

main()

### FIXED CODE ###

import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : map(int, stdin.readline().split())

def main():
  n = ni()
  a = list(na())
  d = {}
  for i, a in enumerate(a):
    d[a] = i+1
  res = []
  for i in range(n):
    res.append(d[i+1])
  print(*res)

main()
### BUGGY CODE ###

N = int(input())

ans=0
for i in range(N+1):
    c=len(str(i))
    c3=str(i).count("3")
    c5=str(i).count("5")
    c7=str(i).count("7")
    if (c3>0) & (c5>0) & (c7>0) & (c==c3+c5+c7):
        ans+=1
    
print(ans)
        
        


### FIXED CODE ###

N = int(input())

def dfs(s):
    if int(s) > N:
        return 0
    ret = 1 if all(s.count(c) > 0 for c in "753") else 0
    for c in "753":
        ret += dfs(s+c)
    return ret

print(dfs("0"))