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

n = int(input())
V = list(map(int,input().split()))
Vodd = list()
Veven = list()
nodd = 0
neven = 0
for x in range(0,n,2):
    Vodd.append(V[x])
    Veven.append(V[x+1]) 
oddcounts = {x:Vodd.count(x) for x in Vodd}
evencounts = {x:Veven.count(x) for x in Veven}

y = sorted(oddcounts.items(),key=lambda x:x[1],reverse=True)
z = sorted(evencounts.items(),key=lambda x:x[1],reverse=True)

number = len(Vodd) - y[0][1] + len(Veven) - z[0][1]

if y[0][0] == z[0][0]:
    if len(y) == 1:
        y.append((0,0))
    if len(z) == 1:
        z.append((0,0))
    number = min(len(Vodd)-y[1][1]+len(Veven)-z[0][1],len(Vodd)-y[0][1]+len(Veven)-z[1][1])

print(number)

### FIXED CODE ###

from collections import Counter
n = int(input())
V = list(map(int,input().split()))
Vodd = list()
Veven = list()
for x in range(0,n//2):
    Vodd.append(V[2*x])
    Veven.append(V[2*x+1]) 

oddcounts = Counter(Vodd).most_common(2)
evencounts = Counter(Veven).most_common(2)

number = n - oddcounts[0][1] - evencounts[0][1]

if oddcounts[0][0] == evencounts[0][0]:
    if len(oddcounts) == 1:
        a = 0
    else:
        a = oddcounts[1][1]
    if len(evencounts) == 1:
        b = 0
    else:
        b = evencounts[1][1]
    number = min(n - a - evencounts[0][1],n - oddcounts[0][1] - b)

print(number)
### BUGGY CODE ###

s=input()
t=input()
ds=dict()
dt=dict()
ss=''
st=''
for i in s:
    if i not in ds:
        ds[i]=str(len(ds))+' '
    ss+=ds[i]
for i in t:
    if i not in dt:
        dt[i]=str(len(dt))+' '
    st+=dt[i]
#print(ss,st)
print('Yes' if ss==st else 'No')
#print(ds,dt)

### FIXED CODE ###

s=input()
t=input()
ds=dict()
dt=dict()
ss=''
st=''
for i in s:
    if i not in ds:
        ds[i]=str(len(ds))+' '
    ss+=ds[i]
for i in t:
    if i not in dt:
        dt[i]=str(len(dt))+' '
    st+=dt[i]
#print(ss,st)
print('Yes' if ss==st else 'No')
#print(ds,dt)
### BUGGY CODE ###

import sys
n = int(input())
a = list(map(int,input().split()))
for num in a:
  i = a.index(num)
  if(num in a[i+1:]):
    print("NO")
    sys.exit()
print("YES")

### FIXED CODE ###

import sys
n = int(input())
a = list(map(int,input().split()))
'''
for num in a:
  i = a.index(num)
  if(num in a[i+1:]):
    print("NO")
    sys.exit()
print("YES")
'''

i=0
a.sort()
while(i<n-1):
  if(a[i] == a[i+1]):
    print("NO")
    sys.exit()
  i += 1
print("YES")
### BUGGY CODE ###

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

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
ans = 0
prev = 0
s = []
for a in A:
    now = prev + a
    s.append(now)
    prev = now

start = 0
last = s[-1]
for i in s[:-1]:
    ans += (i - start) * (last - i)
    start = i
    
    
print(ans%(10**9+7))
### BUGGY CODE ###

"""
N：都市の数
M:双方向道路の数
"""


class DisjointSet:
    def __init__(self, size):
        self.rank = [0] * size  # rank[x]：ノードxを木の親としたときの木の高さ
        self.p = [0] * size  # p[x]：ノードxの親

        for i in range(N):
            self.p[i] = i  # 自分自身を親
            self.rank[i] = 0  # 最初は自分だけなので木の高さは0

    def same(self, x, y):  # xとyが同じ集合に属しているのかどうかを確認
        return (self.findSet(x) == self.findSet(y))

    def unite(self, x, y):  # 結合
        self.link(self.findSet(x), self.findSet(y))

    def link(self, x_root, y_root):  # x_root(y_root):x(y)が属する集合の親
        if (self.rank[x_root] > self.rank[y_root]):
            self.p[y_root] = x_root
        else:
            self.p[x_root] = y_root
            if self.rank[x_root] == self.rank[y_root]:
                self.rank[y_root] += 1

    def findSet(self, x):  # xが属する集合の親を返す
        if x != self.p[x]:
            self.p[x] = self.findSet(self.p[x])

        return self.p[x]


N, M = map(int, input().split())
ds = DisjointSet(N)
parents = []

for _ in range(M):
    A, B = map(int, input().split())
    ds.unite(A-1, B-1)  # 都市Aと要素Bを結合

for i in range(N):
    parent = ds.findSet(i)

    if parent not in parents:
        parents.append(parent)

print(len(parents)-1)


### FIXED CODE ###

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


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

for _ in range(M):
    A, B = map(int, input().split())
    uf.union(A - 1, B - 1)

roots = uf.roots()
print(len(roots)-1)
### BUGGY CODE ###

#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
import sys
import math
def LI(): return [int(x) for x in sys.stdin.readline().split()]

dd = [(1,0),(-1,0),(0,1),(0,-1)]

def solve():
    h,w,k = LI()
    y,x,s,t = LI()
    y -= 1
    x -= 1
    s -= 1
    t -= 1
    c = [input() for i in range(h)]
    q = [(y,x)]
    d = [[0]*w for i in range(h)]
    while q:
      i,j = q.pop()
      for dy,dx in dd:
          ny,nx = i+dy,j+dx
          if 0 <= ny < h and 0 <= nx < w:
              if c[ny][nx] != "@" and not d[ny][nx]:
                  d[ny][nx] = 1
                  q.append((ny,nx))
    if not d[s][t]:
        print(-1)
        return
    cost = 1/k
    d = defaultdict(lambda : float("inf"))
    for i in range(4):
        d[(y,x,i)] = 0
        q.append((0,y,x,i))

    while q:
        dyx,y,x,p = heappop(q)
        if (y,x) == (s,t):
            print(math.ceil(round(dyx,6)))
            return
        if d[(y,x,p)] < dyx:
            continue

        for i,(dy,dx) in enumerate(dd):
            if i == p:
                nd = dyx + cost
            else:
                nd = math.ceil(round(dyx,6)) + cost
            ny,nx = y+dy, x+dx
            if 0 <= ny < h and 0 <= nx < w:
                if c[ny][nx] != "@":
                    if nd < d[(ny,nx,i)]:
                        d[(ny,nx,i)] = nd
                        heappush(q,(nd,ny,nx,i))
    return

#Solve
if __name__ == "__main__":
    solve()


### FIXED CODE ###

#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
import sys
import math
def LI(): return [int(x) for x in sys.stdin.readline().split()]

dd = [(1,0),(-1,0),(0,1),(0,-1)]

def solve():
    h,w,k = LI()
    y,x,s,t = LI()
    y -= 1
    x -= 1
    s -= 1
    t -= 1
    c = [input() for i in range(h)]
    q = deque([(y,x)])
    d = [[float("inf")]*w for i in range(h)]
    d[y][x] = 0
    while q:
      y,x = q.popleft()
      if (y,x) == (s,t):
          print(d[s][t])
          return
      nd = d[y][x] + 1
      for dy,dx in dd:
          ny,nx = y,x
          for _ in range(k):
              ny += dy
              nx += dx
              if 0 <= ny < h and 0 <= nx < w and c[ny][nx] != "@" and nd <= d[ny][nx]:
                  if nd < d[ny][nx]:
                      d[ny][nx] = nd
                      q.append((ny,nx))
                  continue
              break
    print(-1)
    return

#Solve
if __name__ == "__main__":
    solve()
### BUGGY CODE ###

N = int(input())
A_list = list(map(int, input().split()))
Q = int(input())
for _ in range(Q):
    B, C = map(int, input().split())
    temp = [C if j == B else j for j in A_list]
    print(sum(temp))
    A_list = temp.copy()

### FIXED CODE ###

import collections

N = int(input())
A_list = list(map(int, input().split()))
A_count_list = collections.Counter(A_list)
A_sum = sum(A_list)
Q = int(input())
for _ in range(Q):
    B, C = map(int, input().split())
    A_sum += (C - B)*A_count_list[B]
    A_count_list[C] += A_count_list[B]
    A_count_list[B] = 0
    print(A_sum)
### BUGGY CODE ###

def exp_sum(n:int, k:int, P:list):
    each_sum = []
    mx, total, x = 0, 0, 0
    for i in range(k - 1, n + 1):
        total = exp_val_sum(P[:i])
        total = total - exp_val_sum(P[:(i - k + 1)]) + (P[i - k] + 1) / 2
        each_sum.append(total)
        total = 0

    return max(each_sum)

def exp_val_sum(X:list):
    total = 0
    for i in range(len(X)):
        total += (X[i] + 1) / 2
    return total

def main():

    n, k = map(int, input().split())
    P = list(map(int, input().split()))
    ans = 0
    print(exp_sum(n, k, P))

if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():

    n, k = map(int, input().split())
    P = list(map(int, input().split()))
    # print(exp_sum(n, k, P))
    mx = 0
    for i in range(k):
        mx += (P[i] + 1) / 2
    tmp = mx
    for i in range(k, n):
        tmp += (P[i] - P[i - k]) / 2
        mx = max(mx, tmp)
    print(mx)

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

import numpy
N, K = map(int, input().split())
p = numpy.array(list(map(int, input().split())))
max = 0
for i in range(N-K+1):
    temp = numpy.sum(p[i:i+K])
    if max < temp:
        max = temp
        maxno = i

exsum = 0

for i in range(K):
    dice = list(range(1, p[i+maxno]+1))
    ex = 0
    p2 = 1/len(dice)

    for x in dice:
        px = p2*x
        ex += px
    exsum += ex
print(exsum)

### FIXED CODE ###

import numpy
N, K = map(int, input().split())
p = numpy.array(list(map(int, input().split())))
max = 0
nowsum = 0
for i in range(N-K+1):
    if i == 0:
        nowsum = numpy.sum(p[i:i+K])
    else:
        nowsum = nowsum - p[i-1] + p[i+K-1]
    if max < nowsum:
        max = nowsum
        maxno = i

exsum = 0

for i in range(K):
    temp = p[i+maxno]
    exsum += (0.5*temp*(temp+1))/temp
print(exsum)
### BUGGY CODE ###

mod = 10**9+7

def hurui(n):
  data = [i for i in range(2, n + 1)]
  for d in data:
    data = [x for x in data if (x == d or x % d != 0)]
  return data

MAX = 10**5 + 100

fac = [1]*(MAX+1)
for i in range(1,MAX+1):
    fac[i] = (fac[i-1]*i)%mod

rev_m = [1]*(MAX+1)
rev_m[MAX] = pow(fac[MAX],mod-2,mod)
for i in range(MAX,0,-1):
    rev_m[i-1] = (rev_m[i]*i)%mod

def Comb(n,k):#nCk
    return (fac[n]*rev_m[k]*rev_m[n-k])%mod


N,M = map(int, input().split())
Primes = hurui(4000)
kk = [0]*4000

while M > 1:
  for i,p in enumerate(Primes):
    if M%p == 0:
      kk[i]+=1
      M//=p
      break

ans =1
for k in kk:
  ans *= Comb(k+N-1,k)
  ans %= mod

print(ans)


### FIXED CODE ###

from collections import defaultdict
import sys,heapq,bisect,math,itertools,string

def factors_nojit(n):
    gaps = [1,2,2,4,2,4,2,4,6,2,6]
    length, cycle = 11, 3
    f, fs, nxt = 2, [], 0
    while f * f <= n:
        while n % f == 0:
            fs.append(f)
            n0 = n
            n //= f
        f += gaps[nxt]
        nxt += 1
        if nxt == length:
            nxt = cycle
    if n > 1: fs.append(n)
    return fs

MAX = 10**5 + 100
mod = 10**9+7

fac = [1]*(MAX+1)
for i in range(1,MAX+1):
    fac[i] = (fac[i-1]*i)%mod

rev_m = [1]*(MAX+1)
rev_m[MAX] = pow(fac[MAX],mod-2,mod)
for i in range(MAX,0,-1):
    rev_m[i-1] = (rev_m[i]*i)%mod

def Comb(n,k):#nCk
    return (fac[n]*rev_m[k]*rev_m[n-k])%mod

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

fs =  factors_nojit(M)
fs.sort()

dd = defaultdict(int)
ed = []
for f in fs:
    if dd[f] == 0:
        ed.append(f)
    dd[f] += 1

ans =1
for e in ed:
  k = dd[e]
  ans *= Comb(k+N-1,k)
  ans %= mod

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

import numpy as np
n,k,*a=map(int,open(0).read().split())
for _ in range(k):
  b=np.zeros(n+1,dtype=int)
  for i,c in enumerate(a):
    b[max(0,i-c)]+=1
    b[min(n,c+i+1)]-=1
  b=np.cumsum(b,dtype=int)
  a=b[:-1]
  if all(a==n):
    print(*a)
    exit()
print(*a)

### FIXED CODE ###

n,k,*a=map(int,open(0).read().split())
for _ in range(k):
  b=[0]*(n+1)
  for i,c in enumerate(a):
    b[max(0,i-c)]+=1
    b[min(n,c+i+1)]-=1
  for i in range(n):
    b[i+1]+=b[i]
  a=b[:-1]
  if a==[n]*n:
    print(*a)
    exit()
print(*a)
### BUGGY CODE ###

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

result=0
for i in range(len(li)-2):
  for j in range(i+1,len(li)-1):
    for k in range(j+1,len(li)):
      if li[i]<li[j]+li[k] and li[j]<li[i]+li[k] and li[k]<li[j]+li[i]:
        result+=1
print(result)

### FIXED CODE ###

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

li.sort()
#mod_li=[[i,num] for i,num in enumerate(li)]

result=0
for i in range(len(li)-2):
  tmp=i+2
  for j in range(i+1,len(li)-1):
    for k in range(tmp,len(li)):
      if li[i]+li[j]<=li[k]:
        tmp=k-1
        if tmp-j>0:
          result+=tmp-j
        break
      elif k==len(li)-1:
        tmp=k
        result+=tmp-j
        break
print(result)
### BUGGY CODE ###

from heapq import heappush,heappop,heapify
INF=10**18

def find(x):
    if(par[x]==x):
        return x
    else:
        par[x]=find(par[x])
        return par[x]
def union(a,b):
    a=find(a)
    b=find(b)
    if(a==b):
        return 0
    else:
        if rank[a]>rank[b]:
            par[b]=a
            siz[a]+=siz[b]
        else:
            par[a]=b
            siz[b]+=siz[a]
            if rank[a]==rank[b]:
                rank[b]+=1
def size(a):
    return siz[find(a)]
def same(a,b):
    return find(a)==find(b)

def dijkstra(G,s,g,n):
    que=[(0,s)]
    dist=[INF]*n
    dist[s]=0
    while que:
        mincost,u=heappop(que)
        if(mincost>dist[u]):
            continue
        if(u==g):
            return dist
        if(G[u]):
            for c,v in G[u]:
                if(dist[u]+c<dist[v]):
                    dist[v]=dist[u]+c
                    heappush(que,(dist[v],v))
    return dist

N=int(input())
par=[i for i in range(N)]
siz=[1 for _ in range(N)]
rank=[0 for _ in range(N)]

A=[list(map(int,input().split())) for i in range(N)]

G=[set() for i in range(N)]
Edges=[]
for i in range(N):
    for j in range(N):
        if(i==j):
            continue
        Edges.append([A[i][j],i,j])
Edges.sort(key=lambda x:x[0])

res=0
for i in range(len(Edges)):
    cost,fr,to=Edges[i]
    if not same(fr,to):
        union(fr,to)
        G[fr].add((cost,to))
        G[to].add((cost,fr))
        res+=cost
    else:
        di=dijkstra(G,fr,to,N)
        if di[to]<A[fr][to]:
            print(-1)
            exit()
        if di[to]>cost:
            G[fr].add((cost,to))
            G[to].add((cost,fr))
            res+=cost
print(res)

### FIXED CODE ###

N=int(input())
A=[list(map(int,input().split())) for i in range(N)]
res=0
flag=[[False]*N for i in range(N)]
for k in range(N):
    for i in range(N):
        for j in range(N):
            if A[i][j]>A[i][k]+A[k][j]:
                print(-1)
                exit()
            elif k!=i and k!=j and A[i][j]==A[i][k]+A[k][j] and not flag[i][j] and not flag[j][i]:
                flag[i][j]=True
                flag[j][i]=True
                res-=A[i][j]
ans=sum(sum(A[i]) for i in range(N))//2+res

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

# ABC129C - Typical Stairs
import sys
input = sys.stdin.readline

n, m = list(map(int, input().rstrip().split()))
lst = list(map(int, [input().rstrip() for _ in range(m)]))
MOD = 10 ** 9 + 7

if 0 in lst:
    a, b = 0, 1
if 1 in lst:
    a, b = 1, 0
else:
    a, b = 1, 1

for i in range(2, n + 1):
    if a == 0 and b == 0:
        print(0)
        break
    if i in lst:
        a = b
        b = 0
    else:
        tmp = b
        b = (a + b) % MOD
        a = tmp
else:
    print(b)

### FIXED CODE ###

# ABC129C - Typical Stairs
import sys
input = sys.stdin.readline

n, m = list(map(int, input().rstrip().split()))
skip = set(map(int, [input().rstrip() for _ in range(m)]))
MOD = 10 ** 9 + 7
a = 1 if not 0 in skip else 0
b = 1 if not 1 in skip else 0

for i in range(2, n + 1):
    if a == 0 and b == 0:
        print(0)
        break
    if i in skip:
        a = b
        b = 0
    else:
        tmp = b
        b = (a + b) % MOD
        a = tmp
else:
    print(b)
### BUGGY CODE ###

from math import ceil
def solve(val):
	z = 0
	for i in range(n):
		if h[i] <= val*b:
			pass
		else:
			z += ceil((h[i]-val*b)/float(a-b))
	if z <= val:
		return True
	else:
		return False
n,a,b = map(int,raw_input().split())
h = [input() for i in range(n)]
lo,hi = 1,10**12
while lo < hi:
	mid = lo+(hi-lo)//2
	if solve(mid):
		hi = mid
	else:
		lo = mid+1
print lo

### FIXED CODE ###

from math import ceil
def solve(val):
	z = 0
	for i in range(n):
		if h[i] <= val*b:
			pass
		else:
			z += ((h[i]-val*b-1)/(a-b))+1
	if z <= val:
		return True
	else:
		return False
n,a,b = map(int,raw_input().split())
h = [input() for i in range(n)]
lo,hi = 1,10**9
while lo < hi:
	mid = lo+(hi-lo)//2
	if solve(mid):
		hi = mid
	else:
		lo = mid+1
print lo
### BUGGY CODE ###

import copy
N = input()
N = int(N)
A = input()
array = A.split()
ind = 0
for n in array:
    array[ind] = int(n)
    ind = ind+1

for i in range(N):
    temp = copy.deepcopy(array)
    temp.pop(i)
    out = sorted(temp)
    ind = (N//2)-1
    print(out[ind])


### FIXED CODE ###

N = input()
N = int(N)
A = input()
array = A.split()
ind = 0
for n in array:
    array[ind] = int(n)
    ind = ind+1

sortedarray = sorted(array)

be = sortedarray[(N//2-1)]
af = sortedarray[N//2]
for flag in array:
    if flag <= be:
        print(af)
    else: print(be)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
N, A, B, C, D = map(int, input().split())
mod = 10 ** 9 + 7

class Factorial:
  def __init__(self, n, mod):
    self.f = [1]
    for i in range(1, n + 1):
      self.f.append(self.f[-1] * i % mod)
    self.i = [pow(self.f[-1], mod - 2, mod)]
    for i in range(1, n + 1)[: : -1]:
      self.i.append(self.i[-1] * i % mod)
    self.i.reverse()
  def factorial(self, i):
    return self.f[i]
  def ifactorial(self, i):
    return self.i[i]
  def combi(self, n, k):
    return self.f[n] * self.i[n - k] % mod * self.i[k] % mod

f = Factorial(N, mod)
dp = [0] * (N + 1)
dp[N] = 1
for x in range(A, B + 1):
  for i in range(N + 1):
    u = pow(f.ifactorial(x), C, mod)
    for y in range(C, D + 1):
      if i - x * y >= 0:
        dp[i - x * y] += dp[i] * u % mod * f.ifactorial(y) % mod
      u *= f.ifactorial(x)
      u %= mod
print(dp[0] * f.factorial(N) % mod)

### FIXED CODE ###

import sys
input = sys.stdin.readline
N, A, B, C, D = map(int, input().split())
dp = [[0] * (B + 1) for _ in range(N + 1)]
mod = 10 ** 9 + 7

class Factorial:
  def __init__(self, n, mod):
    self.f = [1]
    for i in range(1, n + 1):
      self.f.append(self.f[-1] * i % mod)
    self.i = [pow(self.f[-1], mod - 2, mod)]
    for i in range(1, n + 1)[: : -1]:
      self.i.append(self.i[-1] * i % mod)
    self.i.reverse()
  def factorial(self, i):
    return self.f[i]
  def ifactorial(self, i):
    return self.i[i]
  def combi(self, n, k):
    return self.f[n] * self.i[n - k] % mod * self.i[k] % mod

f = Factorial(1000 * 1000, mod)
dp[0][A - 1] = 1
for i in range(N):
  for k in range(A - 1, B):
    x = k + 1
    t = 1
    for j in range(1, C): t = t * f.combi(x * j, x) % mod
    for j in range(C, D + 1):
      if i + x * j <= N:
        t = t * f.combi(x * j, x) % mod
        dp[i + x * j][x] += dp[i][k] * f.combi(N - i, x * j) % mod * t % mod * f.ifactorial(j) % mod
        dp[i + x * j][x] %= mod
      else: break
      #print(j, t, dp)
    dp[i][x] += dp[i][k]
    dp[i][x] %= mod
    #print(dp)

res = 0
for k in range(A, B + 1):
  res += dp[-1][k]
  res %= mod
print(res)
### BUGGY CODE ###

n=int(input())
x=[int(i) for i in input().split()]
y=sorted(x)
for i in x:
    if y.index(i)+1>n/2:
        print(y[n//2-1])
    else:
        print(y[n//2])

### FIXED CODE ###

n=int(input())
x=[int(i) for i in input().split()]
y=sorted(x)
for i in x:
    if i>y[n//2-1]:
        print(y[n//2-1])
    else:
        print(y[n//2])
### BUGGY CODE ###

def main(N):
    A = list(map(int, input().split()))
    st_A = set(A)
    if 0 in st_A:
        print(0)
    else:
        x = 1
        for a in A:
            x *= a
        if x > 10 ** 18:
            print(-1)
        else:
            print(x)





if __name__ == '__main__':
    N = int(input())
    main(N)

### FIXED CODE ###

def main(N):
    A = list(map(int, input().split()))
    st_A = set(A)
    if 0 in st_A:
        print(0)
    else:
        x = 1
        for a in A:
            x *= a
            if x > 10 ** 18:
                print(-1)
                exit()
        else:
            print(x)





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

from collections import deque

def cndP(l,n,p1,p2):
    d = set()
    min = sum(l[:])
    length = len(l)
    for i in range(length-n+1):
        s = sum(l[i:i+n])
        if s < min:
            min = s
        if p2 == None:
            if p1 < s:
                d.add(s)
        else:
            if p1 < s < p2:
                d.add(s)
    d.add(min)
    return sorted(d)

def pIsAccptbl(w,k,p):
    tr = 0
    c = 0
    d = deque(w)
    while(d):
        tmp = d.popleft()
        if(tmp > p):
            return False
        
        if( tr + tmp > p):
            tr = tmp
            c += 1
        else:
            tr += tmp
        if c+1>k:
            return False
    return True

n,k = [int(x) for x in input().split()]
w = []
for i in range(n):
    e = int(input())
    w.append(e)

p = max(w)

if(pIsAccptbl(w,k,p)):
    print(p)
else:
    n=2
    p1 = p
    p2 = None
    while(1):
        s = cndP(w,n,p1,p2)
        if not p2 == None:
            if s[0] > p2:
                print(p2)
                break;
        for i in s:
            if(pIsAccptbl(w,k,i)):
                p2 = i
                break
            if(p2==None):
                p1 = i
        n+=1

### FIXED CODE ###

from collections import deque

def isPa(w,k,p):
    tr = 0
    c = 0
    d = deque(w)
    while(d):
        tmp = d.popleft()
        if(tmp > p):
            return False
        
        if( tr + tmp > p):
            tr = tmp
            c += 1
        else:
            tr += tmp
        if c+1>k:
            return False
    return True

def MaxInP(w,k,p):
    maxinp = 0
    tmp = 0
    d = deque(w)
    while(d):
        tmp += d.popleft();
        if(tmp > p):
            if(tmp > maxinp):
                maxinp = tmp
            tmp = 0
    return maxinp

n,k = [int(x) for x in input().split()]
w = deque()
for i in range(n):
    w.append(int(input()))
    
mean = int(sum(w)/k)
maxinp = MaxInP(w,k,mean)

if k == 1:
    print(mean)
else:
    minP = mean
    maxP = maxinp
    while(True):
        m = int ((minP + maxP)/2)
        if ( isPa(w,k,m) ):
            maxP = m
        else:
            minP = m
        if (minP+1 == maxP or minP == maxP):
            print(maxP)
            break
### BUGGY CODE ###

import sys
def input():
    return sys.stdin.readline()[:-1]


import collections
def main():
    N = int(input())
    A = list(map(int,input().split()))
    for i in range(N):
        p = A.pop(i)
        c = collections.Counter(A)
        ans = 0
        for j in c.values():
            ans += j * (j - 1) / 2
        A.insert(i, p)
        print(int(ans))
        

if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
def input():
    return sys.stdin.readline()[:-1]


import collections
def main():
    N = int(input())
    A = list(map(int,input().split()))
    c = collections.Counter(A)
    total = 0
    for j in c.values():
        total += j * (j - 1) / 2
    for i in range(N):
        k = c[A[i]]
        before = k * (k - 1) / 2
        after = (k -1) * (k - 2) / 2
        ans = total - before  + after
        print(int(ans))

if __name__ == "__main__":
    main()