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

N=int(input())
A=list(map(int, input().split()))
ans=0
for i in range(N-1):
	#print(A[N-i-1],A[:N-1-i])
	ans+=A[N-i-1]*(sum(A[:N-1-i]))
	ans=ans%(10**9+7)
					
print(ans)

### FIXED CODE ###

N=int(input())
A=list(map(int, input().split()))
ans=0
SM=sum(A)
for i in range(N-1):
	SM-=A[N-1-i]
	ans+=A[N-i-1]*SM
	ans=ans%(10**9+7)
					
print(ans)
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
for i in range(N):
    print(A.count(i + 1))

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
B = [0] * (N - 1)
for i in range(N - 1):
    B[A[i] - 1] += 1
for i in B:
    print(i)
print("0")
### BUGGY CODE ###

import sys
input = sys.stdin.readline

n=int(input())
s=input().rsplit()[0]

def calc(k):
	D=M=DM=DMC=0
	for i in range(n):
		if k<=i:
			if s[i-k]=="D":
				D-=1
				DM-=M
			elif s[i-k]=="M":
				M-=1
		if s[i]=="D":
			D+=1
		elif s[i]=="M":
			M+=1
			DM+=D
		elif s[i]=="C":
			DMC+=DM
	return DMC

q=int(input())
*k,=map(int,input().split())
ans=[calc(x) for x in k]
print(*ans,sep="\n")

### FIXED CODE ###

import sys
input = sys.stdin.readline

n=int(input())
s=input().rsplit()[0]

def calc(k):
	D=M=DM=DMC=0
	for i in range(n):
		if k<=i:
			if s[i-k]=="D":
				D-=1
				DM-=M
			elif s[i-k]=="M":
				M-=1
		if s[i]=="D":
			D+=1
		elif s[i]=="M":
			M+=1
			DM+=D
		elif s[i]=="C":
			DMC+=DM
	return DMC

q=int(input())
*k,=map(int,input().split())
ans=[calc(x) for x in k]
print(*ans,sep="\n")
### BUGGY CODE ###

# -*- coding: utf-8 -*-

N, M = map(int, input().split())
P = [None] * M
Y = [None] * M
for i in range(M):
    p, y = map(int, input().split())
    P[i] = p
    Y[i] = y

ken = [None] * N
for i in range(N):
    ken[i] = []

for i in range(M):
    ken[P[i] - 1].append(Y[i])

for i in range(N):
    ken[i] = sorted(ken[i])

city_info = [None] * M

k = 0


# 木構造
# def create_bitree(a):
#     # a = int list
#     n = len(a)
#     output = [None] * n
#
#     for i in range(n):
#         if a[i] < _:
#             output[sub_bitree()] = a[i]
#         else:
#             output[sub_bitree()] = a[i]


# count M
while(k < M):
    for l in range(N):
        for m in range(len(ken[l])):
            # ken[l][m]の値によって二分木を作る
            # if city_info[0] is None:
            #     city_info[0] = [ken[l][m], l + 1, m + 1]
            # else:

            city_info[k] = [ken[l][m], l + 1, m + 1]
            k += 1


def create_id(p, x):
    output_p = str(p)
    output_x = str(x)
    p_len = len(output_p)
    x_len = len(output_x)
    while p_len < 6:
        output_p = "0" + output_p
        p_len += 1
    while x_len < 6:
        output_x = "0" + output_x
        x_len += 1

    return output_p + output_x


# 律速？
for i in range(M):
    # Y[i]を探してきてprint
    for j in range(len(city_info)):
        if city_info[j][0] == Y[i]:
            print(create_id(city_info[j][1], city_info[j][2]))
            del city_info[j]
            break


### FIXED CODE ###

# -*- coding: utf-8 -*-

# from time import time
# 
# start = time()


def six(n):
    n_str = str(n)
    while len(n_str) < 6:
        n_str = "0" + n_str

    return n_str


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

id_list = [None] * M
dic_P = {}
info = []
info_idx = 0

for i in range(M):
    P, Y = map(int, input().split())
    id_list[i] = [P, Y, ""]
    if P in dic_P.keys():
        info[dic_P[P]].append([i, P, Y])
    else:
        dic_P[P] = info_idx
        info_idx += 1
        info.append([[i, P, Y]])

for group in info:
    group.sort(key=lambda a_i: a_i[2], reverse=False)
    for i, pair in enumerate(group):
        id = six(pair[1]) + six(i+1)
        id_list[pair[0]] = id

for id in id_list:
    print(id)

# print(time() - start)
### BUGGY CODE ###

R,G,B,N=map(int,input().split())
ans=0
for r in range(N+1):
    if r*R>N:
        break
    else:
        for g in range(N+1):
            if ((r*R)+(g*G))>N:
                break
            else:
                if (N-(r*R)-(g*G))%B==0:
                    ans+=1
print(ans)


### FIXED CODE ###

R,G,B,N=map(int,input().split())
ans=0
for r in range(N+1):
    if r*R>N:
        break
    else:
        for g in range(N+1):
            if ((r*R)+(g*G))>N:
                break
            else:
                if (N-(r*R)-(g*G))%B==0:
                    ans+=1
print(ans)
### BUGGY CODE ###

N = int(input())
P = b = list(map(int, input().split()))

ans = 0
for i in range(N):
    P_i = P[i] 
    if P_i == min(P[:i + 1]):
        ans += 1

print(ans)


### FIXED CODE ###

N = int(input())
P = b = list(map(int, input().split()))

ans = 0
P_min = P[0]
for i in range(N):
    if P[i] <= P_min:
        P_min = P[i]
        ans += 1

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

N = int(input())

power_level = 1

for i in range(N):
    power_level *= (i + 1)


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

### FIXED CODE ###

N = int(input())

power_level = 1

for i in range(N):
    power_level *= (i + 1)
    power_level %= (10**9 + 7)


print(power_level)
### BUGGY CODE ###

# https://beta.atcoder.jp/contests/agc029/tasks/agc029_a


def main():
    S = list(input())
    count = 0
    while len(S) > 0:
        if S.count("B") == 0:
            break
        if S[-1] == "B":
            S = S[0:-1]
            continue

        for i in range(len(S)-1, -1, -1):
            if S[i] == "B":
                count += len(S) - 1 - i
                # print("{}, {}".format(len(S) - 1, i))
                S[i] = "W"
                S = S[0:-1]
                break

    print(count)


if __name__ == '__main__':
    main()


### FIXED CODE ###

# https://beta.atcoder.jp/contests/agc029/tasks/agc029_a


def main():
    S = list(input())
    count = 0
    w_offset = 0
    for i in range(len(S)):
        if S[i] == "W":
            count += i - w_offset
            w_offset += 1

    print(count)


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

input()
ns = [n for n in input()]

answers = []

for i in range(len(ns) - 2):
  for j in range(i+1, len(ns) - 1):
    for k in range(j+1, len(ns)):
      answers.append(''.join([ns[i], ns[j], ns[k]]))
print(len(set(answers)))

### FIXED CODE ###

input()
ns = [n for n in input()]
 
scores = 0
first = []
second = []
third = []
third_nums = None
 
for i in range(len(ns) - 2):
  if ns[i] in first:
    continue
  else:
    first.append(ns[i])
  for j in range(i+1, len(ns) - 1):
    if ''.join([ns[i], ns[j]]) in second:
      continue
    else:
      second.append(''.join([ns[i], ns[j]]))
      third_nums = set(ns[j+1:])
      scores += len(third_nums)
      
print(scores)
### BUGGY CODE ###

#10:30〜10:46
#A.sort()
#1 2  7 20 30  40
#累積和=B
#1 3 10 30 60 100
#下克上可能か判定
#if B[i]*2 >= A[i+1] なら下克上可能　1をappend
#else 不可能 0をappend
#下克上可能リスト（=C）
#10111
#最後に出現した0以降の1の個数をカウント：c
#そして+1する
N=int(input())
A=sorted(map(int,input().split()))
B=[]
for n in range(N):
  B.append(sum(A[:n+1]))
c=0
for n in range(N-1):
  if B[n]*2 >= A[n+1]:
    c+=1
  else:
    c=0
print(c+1)

### FIXED CODE ###

#累積和で毎回sumしない
N=int(input())
A=sorted(map(int,input().split()))
b=0
c=0
for n in range(N-1):
  b += A[n]
  if b*2 >= A[n+1]:
    c+=1
  else:
    c=0
print(c+1)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

H, W = map(int, input().split())
A_array = [input()[:-1] for s in range(H)]

ans_array = [[10000] * W for i in range(H)]
# print(ans_array)

for i, A in enumerate(A_array):
    black_index = [i for i, x in enumerate(A) if x == "#"]
    # print(black_index)
    for black in black_index:
        ans_array = [[
            min(ans_array[h][w],
                abs(h - i) + abs(w - black)) for w in range(W)
        ] for h in range(H)]
print(max([max(ans_array[i]) for i in range(H)]))

### FIXED CODE ###

from scipy import ndimage
import numpy as np
import sys
input = sys.stdin.readline

H, W = map(int, input().split())

A_array = np.array(
    [[0 if s == "#" else 1 for s in input()[:-1]] for i in range(H)])
# print(A_array)


# print(A_array)
b = ndimage.morphology.distance_transform_cdt(
    A_array, metric="taxicab")
print(np.max(b))
### BUGGY CODE ###

# coding: utf-8
# Your code here!
n=int(input())
s=list(input())
ans=0
for i in range(n):
    for j in range(i+1,n):
        if s[i]==s[j]:
            continue
        for k in range(j+1,n):
            if s[j]!=s[k]and s[k]!=s[i] and j-i!=k-j:
                ans+=1
print(ans)

### FIXED CODE ###

# coding: utf-8
# Your code here!
n=int(input())
s=list(input())
ans=0
t=[]
ss=[]
for i in range(n):
    t.append(s[i:])
    ss.append(t[i].count('R'))
    ss.append(t[i].count('G'))
    ss.append(t[i].count('B'))
#print(t)
for i in range(n-2):
    for j in range(i+1,n-1):
        if s[i]==s[j]:
            continue
        else:
            if s[i]=='R' and s[j]=='G'or s[i]=='G'and s[j]=='R':
                ans+=ss[3*(j+1)+2]
                if 2*j-i<n:
                    if s[2*j-i]=='B':
                        ans-=1
            if s[i]=='B' and s[j]=='R'or s[i]=='R'and s[j]=='B':
                ans+=ss[3*(1+j)+1]
                if 2*j-i<n:
                    if s[2*j-i]=='G':
                        ans-=1
            if s[i]=='B' and s[j]=='G'or s[i]=='G'and s[j]=='B':
                ans+=ss[3*j+3]
                if 2*j-i<n:
                    if s[2*j-i]=='R':
                        ans-=1
        #print(ans)
print(ans)
### BUGGY CODE ###

N,K = map(int,input().split())
X = list(map(int,input().split()))
ANS = []
for i in range(N-K+1) :
    L = X[i:K+i]
    cplus = 0
    cminus = 0
    czero = 0
    for j in range(len(L)) :

        if L[j] > 0 :
            cplus += 1
        elif L[j] < 0 :
            cminus += 1
        else :
            czero += 1
    if (cplus == K-czero) or (cminus == K-czero):
        ANS.append(max(abs(min(L)),max(L)))
    else :
        ANS.append(min(abs(min(L))*2+abs(max(L)),abs(max(L))*2+abs(min(L))))
print(min(ANS))


### FIXED CODE ###

N,K = map(int,input().split())
L = list(map(int,input().split()))
ANS = []
for i in range(len(L)-K+1) :
    p = L[i]
    q = L[i+K-1]
    if p*q == 0 :
        r = abs(p-q)
    elif p*q < 0 :
        r = 2*min(abs(p),q) + max(abs(p),q)
    else :
        if p > 0 :
            r = q
        else :
            r = abs(p)
    ANS.append(r)
ans = min(ANS)
print(ans)
### BUGGY CODE ###

from collections import deque

H,W = map(int, input().split())
A = [input() for _ in range(H)]

d = [[10**6]*W for _ in range(H)]

for i in range(H):
    for j in range(W):
        if A[i][j] == "#":
            d[i][j] = 0
            q = deque()
            q.append((i, j, 0))
            while q:
                temp = q.popleft()
                y = temp[0]
                x = temp[1]
                r = temp[2]
                if y != 0:
                    if d[y-1][x] > r+1 and A[y-1][x] == ".":
                        d[y-1][x] = r+1
                        q.append((y-1, x, r+1))
                if y != H-1:
                    if d[y+1][x] > r+1 and A[y+1][x] == ".":
                        d[y+1][x] = r+1
                        q.append((y+1, x, r+1))
                if x != 0:
                    if d[y][x-1] > r+1 and A[y][x-1] == ".":
                        d[y][x-1] = r+1
                        q.append((y, x-1, r+1))
                if x != W-1:
                    if d[y][x+1] > r+1 and A[y][x+1] == ".":
                        d[y][x+1] = r+1
                        q.append((y, x+1, r+1))
                        
ans = 0
for i in range(H):
    ans = max(ans, max(d[i]))
    
print(ans)

### FIXED CODE ###

from collections import deque

H,W = map(int, input().split())
A = [input() for _ in range(H)]

d = [[10**6]*W for _ in range(H)]
q = deque()
for i in range(H):
    for j in range(W):
        if A[i][j] == "#":
            d[i][j] = 0
            q.append((i, j, 0))
            
while q:
    temp = q.popleft()
    y = temp[0]
    x = temp[1]
    r = temp[2]
    if y != 0:
        if d[y-1][x] > r+1 and A[y-1][x] == ".":
            d[y-1][x] = r+1
            q.append((y-1, x, r+1))
    if y != H-1:
        if d[y+1][x] > r+1 and A[y+1][x] == ".":
            d[y+1][x] = r+1
            q.append((y+1, x, r+1))
    if x != 0:
        if d[y][x-1] > r+1 and A[y][x-1] == ".":
            d[y][x-1] = r+1
            q.append((y, x-1, r+1))
    if x != W-1:
        if d[y][x+1] > r+1 and A[y][x+1] == ".":
            d[y][x+1] = r+1
            q.append((y, x+1, r+1))
                        
ans = 0
for i in range(H):
    ans = max(ans, max(d[i]))
    
print(ans)
### BUGGY CODE ###

n, m = map(int, input().split())
value = []
for i in range(m):
    A, B = map(int, input().split())
    C = list(map(int, input().split()))
    binary = 0
    for c in C:
        binary |= 1<<(c-1)
    value.append([A, binary])
    
dp = [100100100] * (1<<n)
dp[0] = 0
for s in range(1<<n):
    for i in range(m):
        t = s | value[i][1]
        cost = dp[s] + value[i][0]
        dp[t] = min(dp[t], cost)
if dp[(1<<n)-1] == 100100100:
    print(-1)
else:
    print(dp[(1<<n)-1])

### FIXED CODE ###

#import sys
#input = sys.stdin.readline
 
n, m = map(int, input().split())
value = []
for i in range(m):
    A, B = map(int, input().split())
    c = sum(1<<(ci-1) for ci in map(int, input().split()))
    value.append([A, c])
    
dp = [100100100] * (1<<n)
dp[0] = 0
for s in range(1<<n):
    for i in range(m):
        t = s | value[i][1]
        cost = dp[s] + value[i][0]
        if dp[t] > cost:
            dp[t] = cost
        
if dp[(1<<n)-1] == 100100100:
    print(-1)
else:
    print(dp[(1<<n)-1])
### BUGGY CODE ###

import bisect
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()


def guchoku(n, m, a):
    tmp = []
    for i in range(n):
        for j in range(n):
            tmp.append(a[i]+a[j])
    tmp.sort(reverse=True)
    return sum(tmp[:m])


def C(mid):
    tmp = []
    for i in a:
        pos = bisect.bisect_right(a, mid-i)
        #tmp += n-pos
        tmp.append(n-pos)
    #print(mid, tmp)
    return sum(tmp) >= m, tmp


ub = a[-1]*2
lb = 0
while ub - lb > 1:
    mid = (ub + lb) // 2  # 仮の答え、これを満たす物の個数を数えたい
    c, order = C(mid)
    if c:
        lb = mid
    else:
        ub = mid

ans = 0
cnt = 0
for x in a[::-1]:
    for y in a[::-1]:
        if x + y <= ub:
            break
        ans += x + y
        cnt += 1
# print(order)

ans += (m-cnt)*ub
print(ans)

### FIXED CODE ###

import bisect

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


def C(mid):
    tmp = 0
    for a in A:
        pos = bisect.bisect_right(A, mid - a)
        tmp += N-pos
    return tmp > M


lb = 0
rb = 10**6
while rb - lb > 1:
    happy = (lb + rb) // 2
    if C(happy):
        lb = happy
    else:
        rb = happy

ans = 0
cnt = 0
for a in A:
    pos = bisect.bisect_right(A, rb - a)
    if pos == N:
        continue
    ans += B[pos]+(N-pos)*a
    cnt += N - pos
ans += (M-cnt)*rb
print(ans)
### BUGGY CODE ###

k,s=map(int,input().split())
ans=0
for x in range(k+1):
  for y in range(k+1):
    for z in range(k+1):
      if x+y+z==s:
        ans+=1
print(ans)


### FIXED CODE ###

k,s=map(int,input().split())
ans=0
for x in range(k+1):
  for y in range(k+1):
    if s-k<=x+y<=s:
      ans+=1
print(ans)
### BUGGY CODE ###

def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
import bisect
import sys
sys.setrecursionlimit(10**6)
mod=998244353
n=i1() 
d=[]
for i in range(n):
  d.append(i2())
d=sorted(d)
dx=[]
dd=[]
for i,j in d:
  dx.append(i)
  dd.append(j)
r=[]
dt=[0 for i in range(n)]
dt[-1]=1
for i in range(n):
 r.append(bisect.bisect_left(dx,dx[i]+dd[i]))


for i in range(n)[::-1]:
  dt[i]=max([i]+dt[i+1:r[i]])      
dp=[0 for i in range(n+1)]
dp[-1]=1
for i in range(n)[::-1]:
  dp[i]+=dp[i+1]
  dp[i]+=dp[dt[i]+1]
  dp[i]%=mod
print(dp[0])    

### FIXED CODE ###

def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
import bisect
mod=998244353
n=int(input())
d=[]
N=1<<(n.bit_length())
t=[-1 for i in range(2*N-1)]

def ud(i,x):
  i+=N-1
  t[i]=x
  while i:
    i=(i-1)>>1
    if t[i*2+1]>t[i*2+2]:t[i]=t[i*2+1]
    else:t[i]=t[i*2+2]
     

def qr(a,b):
    a+=N-1
    b+=N-1
    L = -1
    R = -1
    while a < b:
      if a&1==0:
         if L<t[a]:L = t[a]
      if b&1==0:
         b-=1
         if R<t[b]:R = t[b]
      
      a>>=1
      b>>=1
      
         
    return max(L, R)
 
for i in range(n):
  d.append([int(i) for i in input().split()])
d.sort()
dx=[]
dd=[]
for i,j in d:
  dx.append(i)
  dd.append(j)
for i in range(n)[::-1]:
 tx=dx[i]+dd[i]
 j=bisect.bisect_left(dx,tx)
 tt=qr(i,j)
 if j-1>tt:ud(i,j-1)
 else:ud(i,tt)
dp=[0 for i in range(n+1)]
dp[-1]=1
for i in range(n)[::-1]:
  dp[i]+=dp[i+1]
  dp[i]%=mod
  dp[i]+=dp[t[i+N-1]+1]
  dp[i]%=mod
print(dp[0])
### BUGGY CODE ###

from itertools import combinations
import math
N=int(input())
l1=list(map(int,input().split()))
max_n=max(l1)
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
ans=comb(N,3)
for i,j in combinations(l1,2):
  for k in l1:
    if i+j<=k:
      ans-=1
print(ans)

### FIXED CODE ###

import bisect
N=int(input())
l = list(map(int,input().split()))
l.sort()
ans = 0
for i in range(1,N-1):
  for j in range(i+1,N):
    m=bisect.bisect_right(l,l[j]-l[i])
    if i>m:
      ans+=i-m
print(ans)
### BUGGY CODE ###

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

# 累積和を求めておく
cumsum_e = 0
cumsum_w = 0
for i in range(n):
    if s[i] == 'E':
        cumsum_e += 1
    else:
        cumsum_w += 1

min_change = n + 1
for i in range(n):
    temp_change = 0
    if s[i] == 'E':
        temp_cumsum_e = cumsum_e - 1
        temp_cumsum_w = cumsum_w
    else:
        temp_cumsum_e = cumsum_e
        temp_cumsum_w = cumsum_w - 1

    current_w = 0
    current_e = 0
    for j in range(i):
        if s[j] == 'W':
            current_w += 1

    current_e = i - current_w
    migi_e = temp_cumsum_e - current_e
    temp_change = current_w + migi_e

    if temp_change < min_change:
        min_change = temp_change

print(min_change)

### FIXED CODE ###

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

# 累積和を求めておく
cumsum_e = 0
cumsum_w = 0
for i in range(n):
    if s[i] == 'E':
        cumsum_e += 1
    else:
        cumsum_w += 1

min_change = n + 1
current_e = 0
current_w = 0
for i in range(n):
    temp_change = 0
    migi_e = cumsum_e - current_e
    if s[i] == 'E':
        migi_e -= 1
    temp_change = current_w + migi_e

    if temp_change < min_change:
        min_change = temp_change

    if s[i] == 'E':
        current_e += 1
    else:
        current_w += 1

print(min_change)
### BUGGY CODE ###

s=input()
n=len(s)
si=int(s)
mod=2019
from collections import defaultdict
t=defaultdict(lambda:0)
for i in range(n):
    t[int(s[i:])%mod]+=1
t[0]+=1
ans=0
for v in t.values():
    ans+=(v*(v-1))//2
print(ans)

### FIXED CODE ###

s=input()
n=len(s)
mod=2019
sum=0
p=1
d={}
d[0]=1
for i in range(n-1,-1,-1):
    sum=(sum+int(s[i])*p)%mod
    if sum in d:
        d[sum]+=1
    else:
        d[sum]=1
    p=(p*10)%mod
ans=0
for v in d.values():
    ans+=(v*(v-1))//2
print(ans)
### BUGGY CODE ###

import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

def solve():
    n = int(input())
    if is_prime(n):
        print(n-1)
        return
    half = int(math.sqrt(n))
    for i in range(half, n):
        if n % i == 0:
            a = i
            b = n // i
            print(a + b - 2)
            return
    return 

if __name__ == '__main__':
    solve()

### FIXED CODE ###

import math

def is_prime(n):
    if n == 1: return (False, -1)

    for k in range(int(math.sqrt(n)) + 1, 1, -1):
        if n % k == 0:
            return (False, k)

    return (True, 1)

def solve():
    n = int(input())
    p, k = is_prime(n)
    if p:
        print(n-1)
        return
    l = n // k
    print(k + l - 2)
    return
    '''
    half = int(math.sqrt(n))
    for i in range(half, n):
        if n % i == 0:
            a = i
            b = n // i
            print(a + b - 2)
            return
    return 
    '''

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

n = int(input())
A = list(map(int,input().split()))
for i in range(1,n+1):
    print(A.count(i))

### FIXED CODE ###

n = int(input())
A = list(map(int,input().split()))
ans_l = [0]*n
for i in A:
    ans_l[i-1]+=1
for i in ans_l:
    print(i)
### BUGGY CODE ###

n = int(input(''))
adl = input('')

a = list(map(int,adl.split(' ')))

number = 0

mod = 7+1000000000

amari = 0

for i in range(n):
    aa = 0
    for e in range(n-i-1):
        j = i+e+1
        if i != j:
            aa = aa + a[j]
    number = number + (a[i] * aa)
    if number >= mod:
        number = number % mod
amari = number % mod
print(amari)


### FIXED CODE ###

n = int(input(''))
adl = input('')

a = list(map(int,adl.split(' ')))

number = 0

mod = 1000000007

amari = 0

all_a = 0

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

for i in range(n):
    all_a = all_a - a[i]
    number = number + (a[i] * all_a)
    number = number % mod
amari = number % mod
print(amari)
### BUGGY CODE ###

n,Q = [int(i) for i in input().split()]
from heapq import  *

stx=[]
for j in range(n):
    a = [int(i) for i in input().split()]
    stx.append([a[0]-a[2],a[1]-a[2],a[2]])
q = [int(input()) for i in range(Q)]
stx.sort()

xt=[]
pt=0
for d in q:
    while pt < n and stx[pt][0] <= d:
        heappush(xt,(stx[pt][2],stx[pt][1]))
        pt+=1
    while xt and xt[0][1] <= d:
        heappop(xt)
    if xt:
        print(xt[0][0])
    else:
        print(-1)

### FIXED CODE ###

import sys
from heapq import *
input = sys.stdin.readline

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

stx=[[0]*3 for _ in range(n)]
for j in range(n):
    a = [int(i) for i in input().split()]
    stx[j]=[a[0]-a[2],a[1]-a[2],a[2]]
q = [int(input()) for i in range(Q)]
stx.sort()

xt=[]
pt=0
for d in q:
    while pt < n and stx[pt][0] <= d:
        heappush(xt,(stx[pt][2],stx[pt][1]))
        pt+=1
    while xt and xt[0][1] <= d:
        heappop(xt)
    if xt:
        print(xt[0][0])
    else:
        print(-1)
### BUGGY CODE ###

S = list(input())
N = len(S)

while(True):
    if len(S) <= 1:
        break

    popped = False
    for i in range(len(S)-1):
        if S[i] != S[i+1]:
            S.pop(i)
            S.pop(i)
            popped = True
            break

    if not popped:
        break

print(N-len(S))

### FIXED CODE ###

S = input()
red_count = S.count('0')
blue_count = S.count('1')
print(min(red_count, blue_count) * 2)
### BUGGY CODE ###

from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

N = read()
S = input()

former = defaultdict(int)
latter = defaultdict(int)

for bits in range(1 << N):
  bs1 = []; rs1 = []; bs2 = []; rs2 = []
  for i in range(N):
    if (1 << i) & bits:
      rs1.append(S[i])
      rs2.append(S[N+i])
    else:
      bs1.append(S[i])
      bs2.append(S[N+i])
  former["".join(rs1), "".join(bs1)] += 1
  latter["".join(reversed(bs2)), "".join(reversed(rs2))] += 1

ans = 0
for s in former.keys():
  ans += former[s] * latter[s]

print(ans)

### FIXED CODE ###

from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

N = read()
S = input()

former = defaultdict(int)
latter = defaultdict(int)

for bits in range(1 << N):
  bs1 = []; rs1 = []; bs2 = []; rs2 = []
  for i in range(N):
    if (1 << i) & bits:
      rs1.append(S[i])
      rs2.append(S[-1-i])
    else:
      bs1.append(S[i])
      bs2.append(S[-1-i])
  former["".join(rs1), "".join(bs1)] += 1
  latter["".join(bs2), "".join(rs2)] += 1

ans = 0
for k, v in former.items():
  if k in latter:
    ans += v * latter[k]

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

n=int(input())
p=[i+1 for i in range(n)]
ans=sum(p)-p[n-1]
print(ans)

### FIXED CODE ###

n=int(input())
ans=n*(n-1)//2
print(ans)