Harryxun/stf_run huggingface dataset:
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int

memory = {}


def dfs(stones, N, depth):
    if N <= 2:
        # print(" "*depth, stones, "leaf")
        return 1
    # print(" "*depth, stones)
    if stones in memory:
        return memory[stones]

    # ans1 はじめの石使わない
    # print(" "*depth, "ans1")
    ans1 = dfs(stones[1:], N-1, depth+1)

    # ans2 はじめの石を使う
    try:
        ind = stones[2:].index(stones[0])
        # print(" "*depth, "ans2", c)
        # print(" "*depth, ind, stones, stones[ind:])
        ans2 = dfs(stones[2+ind:], N-ind-2, depth+1)
    except:
        ans2 = 0

    ans = (ans1 + ans2) % MOD
    memory[stones] = ans
    return ans


def solve(N: int, C: "List[int]"):
    # print(dfs(tuple(C), N, 0))

    dp = [0]*N
    last = [-1]*N
    for i, s in enumerate(C):
        if i == 0:
            dp[i] = 1
        else:
            dp[i] = dp[i-1]
            if last[s] != -1 and last[s] < i-1:
                dp[i] += dp[last[s]]
        last[s] = i
    # print(dp, souwa, pre)
    print(dp[-1])
    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    C = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, C)


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int

memory = {}


def solve(N: int, C: "List[int]"):
    # print(dfs(tuple(C), N, 0))

    dp = [0]*N
    last = [-1]*(2*(10**5)+1)
    for i, s in enumerate(C):
        if i == 0:
            dp[i] = 1
        else:
            dp[i] = dp[i-1]
            if last[s] != -1 and last[s] < i-1:
                dp[i] = (dp[i] + dp[last[s]]) % MOD
        last[s] = i
    # print(dp, souwa, pre)
    print(dp[-1])
    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    C = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, C)


if __name__ == '__main__':
    main()
import math
H, W = map(int, input().split())
S = []
for i in range(H):
  S.append(str(input()))
d = [[float('inf') for i in range(V)] for j in range(V)]
  
  

### FIXED CODE ###

import math
import sys
sys.setrecursionlimit(10000)
H, W = map(int, input().split())
S = []
for i in range(H):
  S.append(str(input()))
  
def main(l, d, cnt):
  tmp = []
  for n in l:
    i, j = n[0], n[1]
    if (0<i) and (S[i-1][j] == '.'):
      if d[i-1][j] > d[i][j]+1:
        d[i-1][j] = d[i][j]+1
        tmp.append([i-1, j])
    if (i<H-1) and (S[i+1][j] == '.'):
      if d[i+1][j] > d[i][j]+1:
        d[i+1][j] = d[i][j]+1
        tmp.append([i+1, j])
    if (0<j) and (S[i][j-1] == '.'):
      if d[i][j-1] > d[i][j]+1:
        d[i][j-1] = d[i][j]+1
        tmp.append([i, j-1])
    if (j<W-1) and (S[i][j+1] == '.'):
      if d[i][j+1] > d[i][j]+1:
        d[i][j+1] = d[i][j]+1
        tmp.append([i, j+1])
  if tmp == []:
    return cnt
  else:
    cnt += 1
    return main(tmp, d, cnt)
  
ans = 0
for i in range(H):
  for j in range(W):
    if S[i][j] == '.':
      d = [[float('inf') for i in range(W)] for j in range(H)]
      d[i][j] = 0
      cnt = main([[i, j]], d, 0)
      ans = max(ans, cnt)
print(ans)
#!/usr/bin python3
# -*- coding: utf-8 -*-

import numpy as np

r, c, k = map(int, input().split())
itm = [[0]*(c) for _ in range(r)]
for i in range(k):
    ri, ci, vi = map(int, input().split())
    itm[ri-1][ci-1] = vi

dp = np.zeros((3005, 3005, 4), dtype=np.int64)

for i in range(r):
    for j in range(c):
        nowv = itm[i][j]
        dp[i][j][3] = max(dp[i][j][3], dp[i][j][2] + nowv)
        dp[i][j][2] = max(dp[i][j][2], dp[i][j][1] + nowv)
        dp[i][j][1] = max(dp[i][j][1], dp[i][j][0] + nowv)

        dp[i+1][j][0] = max(dp[i+1][j][0], max(dp[i][j]))
        dp[i][j+1][0] = max(dp[i][j+1][0], dp[i][j][0])
        dp[i][j+1][1] = max(dp[i][j+1][1], dp[i][j][1])
        dp[i][j+1][2] = max(dp[i][j+1][2], dp[i][j][2])
        dp[i][j+1][3] = max(dp[i][j+1][2], dp[i][j][3])

print(max(dp[r-1][c-1]))


### FIXED CODE ###

#!/usr/bin python3
# -*- coding: utf-8 -*-

r, c, k = map(int, input().split())
itm = [[0]*(c) for _ in range(r)]
for i in range(k):
    ri, ci, vi = map(int, input().split())
    itm[ri-1][ci-1] = vi

dp0 = [[0]*4 for c_ in range(3005)]
dp1 = [[0]*4 for c_ in range(3005)]

for i in range(r):
    for j in range(c):
        nowv = itm[i][j]
        dp0[j][3] = max(dp0[j][3], dp0[j][2] + nowv)
        dp0[j][2] = max(dp0[j][2], dp0[j][1] + nowv)
        dp0[j][1] = max(dp0[j][1], dp0[j][0] + nowv)

        dp0[j+1][0] = max(dp0[j+1][0], dp0[j][0])
        dp0[j+1][1] = max(dp0[j+1][1], dp0[j][1])
        dp0[j+1][2] = max(dp0[j+1][2], dp0[j][2])
        dp0[j+1][3] = max(dp0[j+1][3], dp0[j][3])

        dp1[j][0] = max(dp1[j][0], max(dp0[j]))
    dp0 = dp1.copy()

print(max(dp1[c-1]))
N,u,v = map(int,input().split())
u -= 1
v -= 1

du = [0]*N
dv = [0]*N
du[u] = 0
dv[v] = 0
G = [[]]*N

def dfs(v, d, p, dis):
    dis[v] = d
    if G[v] != 0:
        for u in G[v]:
            if( u == p):
                continue
            else:
                dfs( u, d+1, v, dis )

def calcDist(s, dist):
    dfs(s, 0, -1, dist)

for i in range(N-1):
    e1,e2 = map(int, input().split())
    e1 -= 1
    e2 -= 1
    if G[e1] == []:
        G[e1] = [e2]
    else:
        G[e1].append(e2)
    if G[e2] == []:
        G[e2] = [e1]
    else:
        G[e2].append(e1)

if G[u]==[v]:
    ans = 0
else:    

    calcDist(v,dv)
    calcDist(u,du)
    maxD = 0
    for idu,idv in zip(du,dv):
        if idu < idv:
            maxD = max(maxD, idv)       
    ans = maxD-1
    
print(ans)

### FIXED CODE ###

A = int(input())
B = int(input())

print(1+2+3-A-B)
num = int(input())
num_1 = num % 10
if num_1 = 2,4,5,7,9:
  print('hon')
elif num_1 = 0,1,6,8:
  print('pon')
else:
  print('bon')

### FIXED CODE ###

num = int(input())
num_1 = num % 10
if num_1 == 3:
  print('bon')
elif num_1 <= 1 or num_1 == 6 or num_1 == 8:
  print('pon')
else:
  print('hon')
import sys

#+++++
		
def main():
	n = int(input())
	ll=[int(input()) for _ in range(n)]
	
	mm = ll.sort()
	ma=mm[-1]
	mb=mm[-2]
	
	for i in ll:
		pp = ma if i != ma else mb:
		print(pp)
		
	
	
	
#+++++

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
	else:
		input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

### FIXED CODE ###

import sys

#+++++
		
def main():
	n = int(input())
	ll=[int(input()) for _ in range(n)]
	
	mm = sorted(ll)
	#print(ll)
	ma=mm[-1]
	mb=mm[-2]
	
	for i in ll:
		pp = ma if i != ma else mb
		print(pp)
		
	
	
	
#+++++

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
	else:
		input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)
a,b = raw_input(), raw_input()
print a*b if 1 <= a <= 9 and 1 <= b <= 9 else -1

### FIXED CODE ###

get = lambda: int(raw_input().strip())
getl = lambda: raw_input().strip()
gets = lambda: map(int, raw_input().strip().split())
getss = lambda n: [gets() for _ in xrange(n)]

a, b = gets()
print a * b if 1 <= a <= 9 and 1 <= b <= 9 else -1
a='abcdefghijklmnopqrstuvwxyz'
l=[0]*26
while True:
    try:
        text=raw_input()
    except EOFError:
        break
    for i in text:
        ascNum=ord(i.lower())-97
        l[ascNum]+=1
for i in xrange(26):
    print a[i] + ' : '+str(l[i])

### FIXED CODE ###

a='abcdefghijklmnopqrstuvwxyz'
l=[0]*26
while True:
    try:
        text=raw_input()
    except EOFError:
        break
    for i in text:
        ascNum=ord(i.lower())-97
        if ascNum < 0 or 25 < ascNum:
            continue
        l[ascNum]+=1
for i in xrange(26):
    print a[i] + ' : '+str(l[i])
N=int(input())
A=list(map(int,input().split()))
B=[0]*100000
total=0
mini=1000000000000000000
for i in range(N):
    total+=A[i]
    B[i]=total

for i in range(N-1):
    if abs(B[i]-(B[N-1]-B[i]))<mini:
        mini=abs(B[i] - (B[N - 1] - B[i]))
print(mini)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
B=[0]*200000
total=0
mini=1000000000000000000
for i in range(N):
    total+=A[i]
    B[i]=total

for i in range(N-1):
    if abs(B[i]-(B[N-1]-B[i]))<mini:
        mini=abs(B[i] - (B[N - 1] - B[i]))
print(mini)
def nCk(n, k):
    ans = 1
    i = 0
    while i < k:
        ans *= n - i
        i += 1
    i = 1
    while i <= k:
        ans /= i
        i += 1
    return ans

def main():
    [N, P] = map(int, raw_input().split())
    even = 0
    odd = 0
    A = map(int, raw_input().split())
    i = 0
    while i < N:
        if 0 == A[i] & 1:
            even += 1
        else:
            odd += 1
        i += 1
    i = P
    k = 0
    while i <= odd:
        k += nCk(odd, i)
        i += 2
    print((2 ** even) * k)

main()

### FIXED CODE ###

def nCk(n, k):
    ans = 1
    i = 0
    while i < k:
        ans *= n - i
        i += 1
    i = 1
    while i <= k:
        ans /= i
        i += 1
    return ans

def main():
    [N, P] = map(int, raw_input().split())
    even = 0
    odd = 0
    A = map(int, raw_input().split())
    i = 0
    while i < N:
        if 0 == A[i] & 1:
            even += 1
        else:
            odd += 1
        i += 1
    i = P
    k = 0
    while i <= odd:
        k += nCk(odd, i)
        i += 2
    print((2 ** even) * k)

if __name__ == '__main__':
    main()
while 1;
 H = input()
 W = input()

  for i in range(H);{
    for k in range(W);{
      print'#'
     }
      print"/n"
      if(H =0 and W =0);
        break
  }

### FIXED CODE ###

while 1:
  H, W = map(int, raw_input().split())
  
  if W == 0 and H == 0:
    break
  
  for i in range(H):
    print "#" * W
  print""
#### import numpy as np
N,M = map(int,input().split())
R = [[] for _ in range(M)]
ans = np.zeros(N,dtype=int)
ans[0] = 1
queue = [1]
for i in range(M):
    i,j = map(int,input().split())
    R[i-1].append(j)
    R[j-1].append(i)
    
def bfs(queue):
    if queue==[]:
        return
    i = queue[0]
    for j in R[i-1]:
        if ans[j-1]!=0:
            continue
        else:
            ans[j-1]=i
            queue.append(j)
    queue.pop(0)
    bfs(queue)
bfs(queue)
if len(ans[ans==0])>0:
    print('No')
else:
    print('Yes')
    for i in range(1,N):
        print(ans[i])

### FIXED CODE ###

import numpy as np
import sys
sys.setrecursionlimit(10**7)
N,M = map(int,input().split())
R = [[] for _ in range(N)]
ans = np.zeros(N,dtype=int)
ans[0] = 1
queue = [1]
for _ in range(M):
    i,j = map(int,input().split())
    R[i-1].append(j)
    R[j-1].append(i)
    
def bfs(que):
    if que==[]:
        return
    i = que[0]
    for j in R[i-1]:
        if ans[j-1]==0:
            ans[j-1]=i
            que.append(j)
    que.pop(0)
    bfs(que)
    
bfs(queue)
print('Yes')
for i in range(1,N):
    print(ans[i])
import numpy as np
import math

n , k = list(map(int, input().split()))
kaijou = np.zeros((n + 1,k + 1))
def combi(a,b):
    if kaijou[a][b] == 0:
        kaijou[a][b] = math.factorial(a) / (math.factorial(b) * math.factorial(a-b))
    return kaijou[a][b]
i = 2
mod = 10 ** 9 + 7
for i in range(1, k + 1):
    print(int(combi(n - k + 1,i) * combi(k - 1, i - 1) % mod))

### FIXED CODE ###

import numpy as np
import math

n , k = list(map(int, input().split()))
def combi(a,b):
    return  math.factorial(a) // (math.factorial(b) * math.factorial(a-b))
i = 2
mod = 10 ** 9 + 7
for i in range(1, k + 1):
    if n - k + 1 >= i and k - 1 >= i - 1:
        print(int(combi(n - k + 1,i) * combi(k - 1, i - 1) % mod))
    else:
        print(0)
N, K = map(int, input())

print(N-K+1)

### FIXED CODE ###

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

print(N-K+1)
import sys
while(1):
  H,W = map(int, raw_input().split())
  if H==0 and W==0:
    break
  for i in range(H):
    sys.stdout.white("#")
    for j in range(1,W-1):
      if i == 1 or i == H:
        sys.stdout.write("#")
      else:
        sys.stdout.write(".")
    sys.stdout.white("#\n")
  print ""    

### FIXED CODE ###

while(1):
  H,W = map(int, raw_input().split())
  if H == 0 and W == 0:
    break
  for i in range(H):
    if i == 0 or i == H-1:
      print "#"*W
    else:
      print "#" + "."*(W-2) + "#"
  print ""
x=int(input())　　#intで整数と指定　、input()は入力されたデータを文字列として返す。
a=int(input())
b=int(input())
print((x-a)%b)

### FIXED CODE ###

x=int(input())
a=int(input())
b=int(input())
print((x-a)%b)
class UF():
  def __init__(self, N):
    self._parent=[n for n in range(0, N)]
    self._size=[1] * N

  def find_root(self, x):
    if self._parent[x]==x:return x
    self._parent[x]=self.find_root(self._parent[x])
    return self._parent[x]

  def unite(self, x, y):
    gx=self.find_root(x)
    gy=self.find_root(y)
    if gx==gy:return

    if self._size[gx]<self._size[gy]:
      self._parent[gx]=gy
      self._size[gy]+=self._size[gx]
    else:
      self._parent[gy]=gx
      self._size[gx]+=self._size[gy]

  def size(self, x):
    return self._size[self.find_root(x)]

  def samegroup(self, x, y):
    return self.find_root(x)==self.find_root(y)

  def groupnum(self):
    N=len(self._parent)
    ans=0
    for i in range(N):
      if self.find_root(i)==i:
        ans+=1
    return ans

from collections import defaultdict
h,w=map(int,input().split())
s=[list(input()) for i in range(h)]
UF=UF(h*w)
for i in range(h):
  for j in range(w):
    if i!=0:
      if s[i][j]!=s[i-1][j]:UF.unite(i*h+j,(i-1)*h+j)
    if i!=h-1:
      if s[i][j]!=s[i+1][j]:UF.unite(i*h+j,(i+1)*h+j)
    if j!=0:
      if s[i][j]!=s[i][j-1]:UF.unite(i*h+j,i*h+(j-1))
    if j!=w-1:
      if s[i][j]!=s[i][j+1]:UF.unite(i*h+j,i*h+(j+1))
listB=[0 for i in range(h*w)]
listW=[0 for i in range(h*w)]
for i in range(h):
  for j in range(w):
    if s[i][j]=='#':
      listB[UF.find_root(i*h+j)]+=1
    else:
      listW[UF.find_root(i*h+j)]+=1
ct=0
for i in range(h*w):
  ct+=listB[i]*listW[i]
print(ct)

### FIXED CODE ###

class UF():
  def __init__(self, N):
    self._parent=[n for n in range(0, N)]
    self._size=[1] * N

  def find_root(self, x):
    if self._parent[x]==x:return x
    self._parent[x]=self.find_root(self._parent[x])
    return self._parent[x]

  def unite(self, x, y):
    gx=self.find_root(x)
    gy=self.find_root(y)
    if gx==gy:return

    if self._size[gx]<self._size[gy]:
      self._parent[gx]=gy
      self._size[gy]+=self._size[gx]
    else:
      self._parent[gy]=gx
      self._size[gx]+=self._size[gy]

  def size(self, x):
    return self._size[self.find_root(x)]

  def samegroup(self, x, y):
    return self.find_root(x)==self.find_root(y)

  def groupnum(self):
    N=len(self._parent)
    ans=0
    for i in range(N):
      if self.find_root(i)==i:
        ans+=1
    return ans

from collections import defaultdict
h,w=map(int,input().split())
s=[list(input()) for i in range(h)]
UF=UF(h*w)
for i in range(h):
  for j in range(w):
    if i!=0:
      if s[i][j]!=s[i-1][j]:UF.unite(i*w+j,(i-1)*w+j)
    if i!=h-1:
      if s[i][j]!=s[i+1][j]:UF.unite(i*w+j,(i+1)*w+j)
    if j!=0:
      if s[i][j]!=s[i][j-1]:UF.unite(i*w+j,i*w+(j-1))
    if j!=w-1:
      if s[i][j]!=s[i][j+1]:UF.unite(i*w+j,i*w+(j+1))
listB=[0 for i in range(h*w)]
listW=[0 for i in range(h*w)]
for i in range(h):
  for j in range(w):
    if s[i][j]=='#':
      listB[UF.find_root(i*w+j)]+=1
    else:
      listW[UF.find_root(i*w+j)]+=1
ct=0
for i in range(h*w):
  ct+=listB[i]*listW[i]
print(ct)
import sys,string

rot1 = string.maketrans("abcdefghijklmnopqrstuvwxyz. ",\
                        "bcdefghijklmnopqrstuvwxyza. ")

for line in sys.stdin:
    while 1:
        if line.count("the") or line.count("this") or line.count("that"):
            print line
            break
        line = text.translate(rot1)

### FIXED CODE ###

import sys,string
A = 'abcdefghijklmnopqrstuvwxyza'
rot = string.maketrans(A[1:], A[:-1])
for line in sys.stdin:
    line = line[:-1]
    while 1:
        if line.count("the") or line.count("this") or line.count("that"):
            print line
            break
        line = line.translate(rot)
import math
a,b = list(map(int,input().split()))
print(abs(a*b)//math.gcd(a,b))

### FIXED CODE ###

def hcf(a,b):
	if(a==0):
		return b
	if(b==0):
		return a
	return hcf(b%a,a)
import math
a,b = list(map(int,input().split()))
print(abs(a*b)//hcf(a,b))
import math
n=int(input())
a=list(map(int, input().split()))
ans=[0]*(n-1)
ans2=[0]*(n-2)

for i in range(1,n):
    ans[i-1] = math.gcd(a[0], a[i])
for i in range(2,n):
    ans2[i-2] = math.gcd(a[1], a[i])
sorted(ans)
sorted(ans2)

if n==3:
    print(max(ans[0],ans2[0]))
elif n==2:
    print(max(a))
else:
    print(max(ans[1],ans2[1]))

### FIXED CODE ###

import fractions

n=int(input())
a=list(map(int, input().split()))
ans=[0]*n
left=[0]*n
right=[0]*n
max_=0

for i in range(n):
  if i==0:
    left[i]=a[0]
  else:
    left[i]=fractions.gcd(left[i-1],a[i])
for i in range(n-1,-1,-1):
  if i==n-1:
    right[i]=a[n-1]
  else:
    right[i]=fractions.gcd(right[i+1],a[i])
for i in range(n):
  if i==0:
    ans=right[1]
  elif i==n-1:
    ans=left[n-2]
  else:
    ans=fractions.gcd(left[i-1],right[i+1])
  if ans>max_:
    max_=ans
    
print(max_)
import numpy as np
N = int(input())
h = list(map(int, input().split()))
default = 10000
dp = [default] * N

def rec(i):
  if i == 0:
    dp[i] = 0
    return 0
  if dp[i] != default:
    return dp[i]
  dp[i] = min(dp[i], rec(i-1)+np.abs(h[i] - h[i-1]))
  if i > 1:
    dp[i] = min(dp[i], rec(i-2)+np.abs(h[i] - h[i-2]))
  return dp[i]
print(rec(N-1))

### FIXED CODE ###

import numpy as np
N = int(input())
h = list(map(int, input().split()))
dp = [9999] * N
dp[0] = 0
for i in range(1,N):
  if i<2:
    dp[i] = dp[i-1] + np.abs(h[i] - h[i-1])
  else:
    min1 = dp[i-2] + np.abs(h[i] - h[i-2])
    min2 = dp[i-1] + np.abs(h[i] - h[i-1])
    dp[i] = min(min1, min2)
print(dp[N-1])
import sys
input = sys.stdin.readline

N, Q = [int(x) for x in input().strip().split()]
res = [0 for _ in range(N)]
tree = [[] for _ in range(N)]
for n in range(N-1):
    a, b = [int(x) for x in input().strip().split()]
    tree[a-1].append(b)

for q in range(Q):
    p, x = [int(x) for x in input().strip().split()]
    res[p-1] += x

def f(n, c):
    res[n-1] += c
    if len(tree[n-1])!=0:
        for num in tree[n-1]:
            f(num, res[n-1])

f(1, 0)
print(*res)

### FIXED CODE ###

import sys
from collections import deque
input = sys.stdin.readline

N, Q = [int(x) for x in input().strip().split()]
res = [0 for _ in range(N)]
tree = [[] for _ in range(N)]
for n in range(N-1):
    a, b = [int(x) for x in input().strip().split()]
    tree[a-1].append(b)

for q in range(Q):
    p, x = [int(x) for x in input().strip().split()]
    res[p-1] += x

q = deque([1])
cq = deque([0])
while q:
    n = q.popleft()
    c = cq.popleft()
    res[n-1] += c
    if len(tree[n-1])!=0:
        for num in tree[n-1]:
            q.append(num)
            cq.append(res[n-1])

print(*res)
n = int(input())
a = list(map(int, input().split()))
result = 1
while result <= 10^(18):
  result *= a[i]
else:
  print(-1)
    
print(result)

### FIXED CODE ###

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

if a.count(0) != 0:
  print(0)
else:
  result = 1
  for i in range(n):
    result *= a[i]
    if result > (10**18):
      print(-1)
      break
    else:
      continue
  else:
    print(result)
N = int(input())
A = list(map(int, input().split()))
l = [0] * 100000
for i in A:
    l[i] += 1
c = 0
nums = [0] * N
for i in range(N):
    nums[i] = l[i] * (l[i] - 1) / 2
s = sum(nums)
for i in range(N):
    a = A[i]
    print(int(s - nums[a] + (l[a] - 1) * (l[a] - 2) / 2))


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
l = [0] * 10000001
for i in A:
    l[i] += 1
s = 0
for i in range(N + 1):
    i = l[i]
    s += i * (i - 1) // 2
for a in A:
    a = l[a]
    print(s - (a * (a - 1) // 2) + ((a - 1) * (a - 2) // 2))
N, M= map(int, input().split())
A = list(map(int, input().split()))    
if N-sum(A)>=0:
    print(N-sum(A))
else:
    print("-1")

### FIXED CODE ###

R=int(input())
import math
print(2*math.pi*R)
N=int(input())
A=list(map(int,input().split()))
temp=1
summ=0
cont=0
templist=[1]
for i in range(N+1):
  #print(temp)
  if A[i]<temp:
    if i<N:
      summ+=temp
      temp=2*(temp-A[i])
      templist.append(temp)
    if i==N:
      summ+=temp
      cont+=1
  elif A[i]==temp:
    if i==N:
      summ+=temp
      #templist.append(temp)
      cont+=1
    else:
      print("-1")
      break
  else:
    print("-1")
    break
    
if cont==1:
  if A[N]==temp:
    print(summ)
  else:
    #print(templist)
    #print(A)
    comp=A[-1]
    for i in range(N+1):
      summ-=(templist[-(i+1)]-comp)
      comp+=A[-(i+2)]
      #print(comp)
      #print(templist[-(i+2)])
      #print(summ)
      if comp>templist[-(i+2)]:
        print(summ)
        break
        

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
temp=1
summ=0
cont=0
templist=[1]
for i in range(N+1):
  #print(temp)
  if A[i]<temp:
    if i<N:
      summ+=temp
      temp=2*(temp-A[i])
      templist.append(temp)
    elif i==N:
      summ+=temp
      cont+=1
  elif A[i]==temp:
    if i==N:
      summ+=temp
      #templist.append(temp)
      cont+=1
    else:
      print("-1")
      break
  else:
    print("-1")
    break
    
if cont==1:
  if A[N]==temp:
  	print(summ)
  else:
    #print(templist)
    #print(A)
    comp=A[-1]
    for i in range(N):
      summ-=(templist[-(i+1)]-comp)
      comp+=A[-(i+2)]
      #print(comp)
      #print(templist[-(i+2)])
      #print(summ)
      if comp>templist[-(i+2)]:
        print(summ)
        break
      if i==N-1:
        print(summ)
        break