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

N = int(input())
As = list(map(int,input().split()))
As.sort(reverse=True)
first_d = As[0]
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

if N == 2:
    print(max(As))
else:
    first = make_divisors(As[0])
    second = make_divisors(As[1])
    
    third  = make_divisors(As[2])
    
    div_list = list((set(first) & set(second)) | (set(first) & set(third)) | (set(third) & set(second)))
    div_list.sort(reverse=True)
    
    for d in range(len(div_list)):
        cnt = 0
        for i in range(N):
            if As[i] % (div_list[d]) == 0:
                cnt += 1
        if cnt >= N-1:
            ans = div_list[d]
            break
    print(ans)



### FIXED CODE ###

N = int(input())
As = list(map(int,input().split()))
As.sort(reverse=True)
first_d = As[0]
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

if N == 2:
    print(max(As))
else:
    first = make_divisors(As[0])
    second = make_divisors(As[1])
    third  = make_divisors(As[2])
    div_list = list((set(first) & set(second)) | (set(first) & set(third)) | (set(third) & set(second)))
    div_list.sort(reverse=True)
    
    for d in range(len(div_list)):
        cnt = 0
        for i in range(N):
            if As[i] % (div_list[d]) != 0:
                cnt += 1
                if cnt > 1:
                    break
        if cnt <= 1 :
            ans = div_list[d]
            break
    print(ans)
### BUGGY CODE ###

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

ll=0
rr=10**9+1
for _ in range(10**3):
  #最も長い丸太がこれになる
  ans=(ll+rr)/2.0
  cnt=0
  for item in a:
    if item>ans:
	    cnt+=((-1*item)//ans)*(-1)-1
  if cnt<=k:
    rr=ans
  else:
    ll=ans
print(int((-1*ans//1)*(-1)))

### FIXED CODE ###

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

ll=0
rr=10**9+1
for _ in range(10**2):
  #最も長い丸太がこれになる
  ans=(ll+rr)/2.0
  cnt=0
  for item in a:
    if item>ans:
	    cnt+=((-1*item)//ans)*(-1)-1
  if cnt<=k:
    rr=ans
  else:
    ll=ans
print(int((-1*ans//1)*(-1)))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**7)
a,b,n = map(int, input().split())

def num(x):
    return (a*x)//b - a*(x//b)

ma = num(1)

for i in range(2, n+1):
    if num(i) > ma:
        ma = num(i)
print(ma)

### FIXED CODE ###

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

x =  min(b-1, n)
print(int(a*x/b) - a*int(x/b))
### BUGGY CODE ###

N = int(input())
match = []

for i in range(1, int((2*N)**(1/2)+1)):
  for j in range(i, int((2*N)**(1/2)+1)):
    for k in range(j, int((2*N)**(1/2)+1)):
      matched = i**2 + j**2 + k**2 + i*j + j*k + k*i
      if i==j==k:
        count = 1
      elif i==j or j==k:
        count = 3
      else:
        count = 6
      for l in range(count):
        match.append(int(matched))

match.sort()

for i in range(1,N+1):
  num = 0
  while i == match[0]:
    match = match[1:]
    num += 1
  print(num)


### FIXED CODE ###

N = int(input())
num = [0 for i in range(7*N)]

for x in range(1, int(N**0.5)+1):
  for y in range(1, int(N**0.5)+1):
    for z in range(1, int(N**0.5)+1):
      f_N = x**2 + y**2 + z**2 + x*y + y*z + z*x
      num[f_N] += 1

for i in range(N):
  print(num[i+1])
### BUGGY CODE ###

N = int(input().strip())

x, y, z = 1, 1, 1

f = []
for i in range(N+1):
    f.append(set())

# while x**2 + y**2 + z**2 + x*y + y*z + x*z <= N:
def calc(x, y, z, f):
    # print(x, y, z)
    n = x**2 + y**2 + z**2 + x*y + y*z + x*z
    if n <= N:
        f[n].add("%d-%d-%d" % (x, y, z))
        # print(n, x, y, z)
        f = calc(x+1, y, z, f)
        f = calc(x, y+1, z, f)
        f = calc(x, y, z+1, f)
        return f
    else:
        return f

f = calc(x, y, z, f)
# while True:
#     f = calc(x, y, z, f)
#     f = calc(x+1, y, z, f)
#     f = calc(x, y+1, z, f)
#     f = calc(x, y, z+1, f)
#     f = calc(x+1, y+1, z, f)
#     f = calc(x, y+1, z+1, f)
#     f = calc(x+1, y, z+1, f)
#
#     x += 1
#     y += 1
#     z += 1
#
#     if x**2 + y**2 + z**2 + x*y + y*z + x*z > N:
#         break

for i in range(1, N+1):
    print(f[i].__len__())

### FIXED CODE ###

N = int(input().strip())

x, y, z = 1, 1, 1

f = [0] * (N + 1)

# while x**2 + y**2 + z**2 + x*y + y*z + x*z <= N:
def calc(x, y, z, f, axis="xyz"):
    # print(x, y, z)
    n = x**2 + y**2 + z**2 + x*y + y*z + x*z

    if n <= N:
        f[n] += 1
        if axis == "xyz":
            f = calc(x+1, y, z, f, axis="xyz")
            f = calc(x, y+1, z, f, axis="yz")
            f = calc(x, y, z+1, f, axis="z")
        elif axis == "yz":
            f = calc(x, y+1, z, f, axis="yz")
            f = calc(x, y, z+1, f, axis="z")
        elif axis == "z":
            f = calc(x, y, z + 1, f, axis="z")
        return f
    else:
        return f

f = calc(x, y, z, f)


for i in range(1, N+1):
    print(f[i])
### BUGGY CODE ###

from itertools import groupby
def calc():
  s = 0
  for i in range(h):
    gr = groupby(g[i])
    j = 0
    for key,it in gr:
      if key==-1: continue
      l = len(list(it))
      if l >= K:
        g[i][j:j+l] = [-1]*l
        # for k in range(l):
        #   g[i][j+k] = -1
        # # print("s", key, l, key*l)
        s += key*l
      j += l
      # print("j", j)

  return s

def flatten():
  for j in range(w):
    lst = []
    for i in range(h-1, -1, -1):
      if g[i][j] > 0:
        lst.append(g[i][j])

    lst += [-1] * (h - len(lst))

    for i in range(h-1, -1, -1):
      g[i][j] = lst[h-i-1]

h,w,K = map(int,input().split())
mat = [ [int(e) for e in list(input())] for _ in range(h) ]

res = 0
for i in range(h):
  for j in range(w):
    score = 0
    g = [ [ mat[n][m] for m in range(w) ] for n in range(h) ]
    g[i][j] = -1
    time = 0
    flatten()
    while True:
      s = calc()
      if s > 0:
        score += pow(2, time) * s
      else:
        break
      flatten()
      time += 1
    res = max(res, score)

print(res)



### FIXED CODE ###

from itertools import groupby

def calc(time):
  t = 0
  for i in range(h):
    gr = groupby(g[i])
    lst = []
    p = 0
    for key,it in gr:
      j = len(list(it))
      lst.append([p,key,j])
      p += j
    for j in range(len(lst)):
      if lst[j][1] == -1:
        continue
      if lst[j][2] >= K:
        t += (2**time)*lst[j][1]*lst[j][2]
        for k in range(lst[j][0],lst[j][0]+lst[j][2]):
          g[i][k] = 0

  return t

def flatten():
  for j in range(w):
    lst = []
    for i in range(h-1, -1, -1):
      if g[i][j] > 0:
        lst.append(g[i][j])

    lst += [-1] * (h - len(lst))

    for i in range(h-1, -1, -1):
      g[i][j] = lst[h-i-1]

h,w,K = map(int,input().split())
mat = [ [int(e) for e in list(input())] for _ in range(h) ]

res = 0
for i in range(h):
  for j in range(w):
    score = 0
    g = [ [ mat[n][m] for m in range(w) ] for n in range(h) ]
    g[i][j] = -1
    time = 0
    flatten()
    while True:
      s = calc(time)
      if s==0: break
      score += s
      flatten()
      time += 1
    res = max(res, score)

print(res)
### BUGGY CODE ###

n = int(input())
a = [int(input()) for i in range(n)]
i = a[0]
num = [1, i]
for k in range(n):
    if 2 in num:
        print(len(num) - 1)
        break
    j = a[i-1]
    if j in num:
        print(-1)
        break
    num.append(j)
    if 2 in num:
        print(len(num) - 1)
        break
    i = a[j-1]
    if i in num:
        print(-1)
        break
    num.append(i)

### FIXED CODE ###

n = int(input())
a = [int(input()) for i in range(n)]
i = a[0]
for j in range(n):
    if i == 2:
        print(j + 1)
        break
    i = a[i-1]
else:
	print(-1)
### BUGGY CODE ###

# coding: UTF-8

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

# print(n, m)

nWA = 0
nAC = []
kariWA = []
numlist = [input() for i in range(m)]

# print(numlist)

for j in numlist:
  crnt = j.split(' ')
  if (crnt[1] == 'AC') and (crnt[0] not in nAC):
    nAC.append(crnt[0])
    nWA += kariWA.count(crnt[0])
  elif crnt[1] == 'WA':
    kariWA.append(crnt[0])

print(len(nAC), nWA)


### FIXED CODE ###

# coding: UTF-8

n, m = map(int, input().split())
AC, WA = 0, 0
nWA = [0]*(n+1)
nAC = [0]*(n+1)

for i in range(m):
    cp, cS = input().split()
    cp = int(cp)
    if cS == 'AC':
        if nAC[cp] == 0:
            AC += 1
            WA += nWA[cp]
            nAC[cp] = 1
    else:
        nWA[cp] += 1
print(AC, WA)
### BUGGY CODE ###

N = int(input())
Ai = [int(i) for i in input().split()]

leftSum = 0
rightSum = 0
K = N

for i in range(0,N):
    if(leftSum < rightSum):
        leftSum = leftSum + Ai.pop(0)
        K = K-1
    else:
        rightSum = rightSum + Ai.pop(K-1)
        K = K-1
print(abs(leftSum-rightSum))

### FIXED CODE ###

N = int(input())
Ai = [int(i) for i in input().split()]

leftSum = 0
rightSum = 0
K = N
L = 0

for i in range(0,N):
    if(leftSum < rightSum):
        leftSum = leftSum + Ai[L]
        L = L+1
    else:
        rightSum = rightSum + Ai[K-1]
        K = K-1
print(abs(leftSum-rightSum))
### BUGGY CODE ###

#editorial
n,q=map(int,input().split())
*qu,=[tuple(map(int, input().split())) for _ in range(q)]
w=n-2;h=n-2
wwh=[n-2]*(n-2)
hhw=[n-2]*(n-2)
b=0
for t,x in qu:
    if t==1:
        x-=2
        b+=wwh[x]
        if x<w:
            for i in range(h):
                hhw[i]=x
            w=x

    else:
        x-=2
        b+=hhw[x]
        if x<h:
            for i in range(w):
                wwh[i]=x
            h=x
    
    ans=(n-2)*(n-2)-b
#    print(wwh)
#    print(hhw)
#    print(h,w)

ans=(n-2)*(n-2)-b
print(ans)
    


### FIXED CODE ###

#editorial
n,q=map(int,input().split())
*qu,=[tuple(map(int, input().split())) for _ in range(q)]
w=n-2;h=n-2
wwh=[n-2]*(n-2)
hhw=[n-2]*(n-2)
b=0
for t,x in qu:
    x-=2
    if t==1:
        
        if x<w:
            b+=h
            for i in range(x,w):
                wwh[i]=h
            w=x
        else:
            b+=wwh[x]

    else:
        if x<h:
            b+=w
            for i in range(x,h):
                hhw[i]=w
            h=x
        else:
            b+=hhw[x]

ans=(n-2)*(n-2)-b
print(ans)
### BUGGY CODE ###

n = int(input())
a_list = list(map(int, input().split()))
ans = 'YES'
cheacked = []

for i in a_list:
    if i in cheacked:
        ans = 'NO'
        break
    else:
        cheacked.append(i)
        
print(ans)

### FIXED CODE ###

n = int(input())
a_list = list(map(int, input().split()))
ans = 'YES'
cheacked = {}

for i in a_list:
    if i in cheacked.keys():
        ans = 'NO'
        break
    else:
        cheacked[i] = 0
        
print(ans)
### BUGGY CODE ###

import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from collections import deque

k = ni()
que = deque([(1,1)])

kmod = [0]*k

while kmod[0] == 0:
    cost, cur = que.popleft()
    if kmod[cur%k] == 0:
        kmod[cur%k] = cost
    
    if kmod[(10*cur)%k] == 0:
        que.appendleft((cost, 10*cur))
    
    if kmod[(cur+1)%k] == 0:
        que.append((cost+1, cur+1))
            
        
print(kmod[0])

### FIXED CODE ###

from collections import deque

def bfs(K:int) -> list:
    hasChecked = [False]*(K+1)
    cost_list = [0]*(K+1)
    cost_list[1] = 1
    
    que = deque([(cost_list[1], 1)])
    
    while que:
        cost, res = que.popleft()
        if hasChecked[res]:
            continue
        
        hasChecked[res] = True
        cost_list[res] = cost
        
        if not hasChecked[10*res%K]:
            que.appendleft((cost, 10*res%K))
            
        if not hasChecked[(res+1)%K]:
            que.append((cost+1, (res+1)%K))
            
            
    return cost_list


K = int(input())
cost_list = bfs(K)
print(cost_list[0])
### BUGGY CODE ###

def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))

    # a<b<c となる並べ方の数
    # b<c となる並べ方の数、１つずつに対してN個調べるO(N^2) => すでにOver => pypy
    # b M個となったとき (b_c_i - b_c_m) を保持する
    # a<b となる並べ方の数、１つずつに対してN個調べるO(M*N)
    # b L個となったとき (b_a_i - b_a_m) を保持する (b_cと対応付ける)

    ans = 0
    for b in B:
        less_b_count = sum(1 for a in A if a < b)
        if less_b_count > 0:
            over_b_count = sum(1 for c in C if b < c)
            ans += less_b_count * over_b_count

    print(ans)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import bisect


def main():
    N = int(input())
    A = sorted(map(int, input().split()))
    B = list(map(int, input().split()))
    C = sorted(map(int, input().split()))

    ans = 0
    for b in B:
        na = bisect.bisect_left(A, b)
        nc = N - bisect.bisect_right(C, b)
        ans += na * nc

    print(ans)


def TLE(N, A, B, C):
    # a<b<c となる並べ方の数
    # b<c となる並べ方の数、１つずつに対してN個調べるO(N^2) => すでにOver => pypy
    # b M個となったとき (b_c_i - b_c_m) を保持する
    # a<b となる並べ方の数、１つずつに対してN個調べるO(M*N)
    # b L個となったとき (b_a_i - b_a_m) を保持する (b_cと対応付ける)

    ans = 0
    for b in B:
        less_b_count = sum(1 for a in A if a < b)
        if less_b_count > 0:
            over_b_count = sum(1 for c in C if b < c)
            ans += less_b_count * over_b_count

    print(ans)

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

n, *a = map(int, open(0).read().split())
print(min(abs(sum(a) - sum(a[:i])*2) for i in range(1, n)))

### FIXED CODE ###

from itertools import*
_, *d = map(int, open(0).read().split())
*a, s = list(accumulate(d))
print(min(abs(s - x*2) for x in a))
### BUGGY CODE ###

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

memo = {}
for i in range(n):
    memo[i] = 0

cnt = 0
while True:
    visited = [False] * n
    flag = False
    for i in range(n):
        if memo[i] == len(a[0]):
            continue
        if visited[i] or visited[a[i][memo[i]] - 1]:
            continue
        visited[i] = True
        if i + 1 == a[a[i][memo[i]] - 1][memo[a[i][memo[i]] - 1]]:
            visited[a[i][memo[i]] - 1] = True
            flag = True
            tmp = memo[i]
            memo[i] += 1
            memo[a[i][tmp] - 1] += 1
    if flag:
        cnt += 1
    else:
        for i in memo:
            if memo[i] != len(a[0]):
                print(-1)
                exit()
        break
print(cnt)

### FIXED CODE ###

import time
s_time = time.time()


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

memo = {}
for i in range(n):
    memo[i] = 0

cnt = 0
while True:
    visited = [False] * n
    flag = False
    for i in range(n):
        if memo[i] == len(a[0]):
            continue
        if visited[i] or visited[a[i][memo[i]] - 1]:
            continue
        visited[i] = True
        if i + 1 == a[a[i][memo[i]] - 1][memo[a[i][memo[i]] - 1]]:
            visited[a[i][memo[i]] - 1] = True
            flag = True
            tmp = memo[i]
            memo[i] += 1
            memo[a[i][tmp] - 1] += 1
    if flag:
        cnt += 1
    else:
        for i in memo:
            if memo[i] != len(a[0]):
                print(-1)
                exit()
        break
    if abs(s_time - time.time()) > 1.7:
        print(n*(n-1) //2)
        exit()
print(cnt)
### BUGGY CODE ###

from collections import deque
S=input()
S_list=deque()
for k in range(len(S)):
    S_list.append(S[k])
Q=int(input())
kouho=[input().split() for i in range(Q)]
"""for i in range(Q):
    kari=input().split()
    kouho.append(kari)"""
for j in range(Q):
    if kouho[j][0]=="1":
        S_list.reverse()
    else:
        if kouho[j][1]=="1":
            S_list.appendleft(kouho[j][2])
        else:
            S_list.append(kouho[j][2])
print(*S_list,sep="")

### FIXED CODE ###

from collections import deque
S=input()
S_list=deque()
for k in range(len(S)):
    S_list.append(S[k])
Q=int(input())
kouho=[input().split() for i in range(Q)]
"""for i in range(Q):
    kari=input().split()
    kouho.append(kari)"""
hanten=[]
count=0
flaag=["sonomama","hantai"]

for j in range(Q):
    flag=flaag[count%2]
    if kouho[j][0]=="1":
        count+=1
    else:
        if flag=="sonomama":
            if kouho[j][1]=="1":
                S_list.appendleft(kouho[j][2])
            else:
                S_list.append(kouho[j][2])
        else:
            if kouho[j][1]!="1":
                S_list.appendleft(kouho[j][2])
            else:
                S_list.append(kouho[j][2])
for k in range(count%2):
    S_list.reverse()
print(*S_list,sep="")
### BUGGY CODE ###

import math
def like_2017(n):
    if n == 1: return False
    if n == 2: return False 

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

q = int(input())
L = [[int(i) for i in input().split()] for _ in range(q)]

for l,r in L:
    length = [i for i in range(l,r+1) if like_2017(i)]
    print(len(length))


### FIXED CODE ###

import math
def like_2017(n):
    if n == 1: return False
    if n == 2: return False 

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

q = int(input())
L = [[int(i) for i in input().split()] for _ in range(q)]
ans = [0 for _ in range(10**5+1)]

for i in range(3,10**5):
    ans[i+1] = ans[i] + 1 if like_2017(i) else ans[i] 

for l,r in L:
    print(ans[r+1] - ans[l])
### BUGGY CODE ###

A, B, C = map(int, input().split())

cnt = 0
while A%2 == B%2 == C%2 == 0:
    x = (B+C)//2
    y = (A+C)//2
    z = (A+B)//2
    A = x
    B = y
    C = z
    cnt += 1

if A == B == C and A%2==0:
    print(-1)
else:
    print(cnt)

### FIXED CODE ###

A, B, C = map(int, input().split())

if A == B == C and A%2==0:
    print(-1)
else:
    cnt = 0
    while A%2 == B%2 == C%2 == 0:
        x = (B+C)//2
        y = (A+C)//2
        z = (A+B)//2
        A = x
        B = y
        C = z
        cnt += 1
    print(cnt)
### BUGGY CODE ###

n, p = map(int, input().split(' '))
s = input()
ans = 0

for i in range(len(s)):
    for j in range(i + 1, len(s) + 1):
        n_ss = int(s[i:j])
        if n_ss % p == 0:
            ans += 1

print(ans)

### FIXED CODE ###

n, p = map(int, input().split(' '))
s = input()

if 10 % p == 0:
    ans = 0
    for i in range(n):
        if int(s[i]) % p == 0:
            ans += i + 1
    print(ans)
else:
    ans = 0
    d = [0 for _ in range(n + 1)]
    ten = 1
    for i in range(n - 1, -1, -1):
        a = int(s[i]) * ten % p
        d[i] = (d[i + 1] + a) % p
        ten *= 10
        ten %= p
    cnt = [0 for _ in range(p)]
    for i in range(n, -1, -1):
        ans += cnt[d[i]]
        cnt[d[i]] += 1
    print(ans)
### BUGGY CODE ###

X = input()
X2 = ""
N = 10**10000
for i in range(N):
	if X2 == X:
		print(len(X))
		break
	else:
		X2 = X
		X = X.replace("ST","")
else:
	print(0)


### FIXED CODE ###

X = input()
stack = []
for l in X:
	if stack == []:
		stack.append(l)
	elif stack[-1] == "S" and l == "T":
		stack.pop()
	else:
		stack.append(l)
print(len(stack))
### BUGGY CODE ###

from math import sqrt
from collections import defaultdict


def sieve(x):
    """
    Sieve of Eratosthenes
    :param x: max value
    :return: list of primes
    """

    primes = []
    li = list(range(2, x + 1))

    while li[0] <= sqrt(x):
        p = li[0]
        primes.append(p)
        li = [e for e in li if e % p != 0]

    primes += li
    return primes


def prime_fact(x):
    for e in p:
        cnt = 0
        while x % e == 0:
            x //= e
            cnt += 1
        pf[e] = max(pf[e], cnt)


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

p = sieve(MAX)
pf = [0] * MAX

for e in a:
    prime_fact(e)

lcm = 1
for i, e in enumerate(pf[1:], 1):
    lcm *= pow(i, e)

ans = 0
for e in a:
    b = lcm // e
    ans += b
    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 ###

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

import sys
from collections import Counter
d = Counter(A)

if d[0] == N:
    print("Yes")
    sys.exit()

if d[0] == N // 3:
    for x in d.keys():
        if d[x] == 2 * N // 3:
            print("Yes")
            sys.exit()

# print(d)
third = N // 3
# print(third)
cand = list(filter(lambda x: d[x] == third, A))
# print(cand)
for ix1 in range(len(cand)):
    for ix2 in range(ix1 + 1, len(cand)):
        for ix3 in range(ix2 + 1, len(cand)):
            if cand[ix1] ^ cand[ix2] ^ cand[ix3] == 0:
                print("Yes")
                sys.exit()

print("No")

### FIXED CODE ###

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

import sys
from collections import Counter
d = Counter(A)

if d[0] == N:
    print("Yes")
    sys.exit()

if d[0] == N // 3:
    for x in d.keys():
        if d[x] == 2 * N // 3:
            print("Yes")
            sys.exit()

third = N // 3
if len(d.keys()) == 3:
    a, b, c = d.keys()
    if d[a] == d[b] and d[b] == d[c]:
        if a ^ b ^ c == 0:
            print("Yes")
            sys.exit()

print("No")
### BUGGY CODE ###

from collections import Counter

S,r = input(),0
dp = list(range(len(S)+1))
dp[-1],dp[-2] = 0,int(S[-1])

for i in range(3,len(S)+2):
	dp[-i] = (dp[-i+1] + 10**(i-2)*int(S[-i+1]))%2019

for x in Counter(dp).values():
	r += x*(x-1)//2
print(r)

### FIXED CODE ###

from collections import Counter

def modpow(a, n, m):
	r = 1
	while n > 0:
		if n & 1:
			r = r*a%m
		a = a*a%m
		n >>= 1
	return r

S,r = input(),0
dp = list(range(len(S)+1))
dp[-1],dp[-2] = 0,int(S[-1])

for i in range(3,len(S)+2):
	dp[-i] = (dp[-i+1] + modpow(10,i-2,2019)*int(S[-i+1])) % 2019

for x in Counter(dp).values():
	r += x*(x-1)//2
print(r)
### BUGGY CODE ###

sn,bn=map(int,input().split(" "))
fubensa=[int(sn*(sn-1)/2)]
if bn>1:
    br=[]
    for _ in range(bn):
        br.append(list(map(int, input().split(" "))))
    br=br[::-1]
    sg=[0 for n in range(sn+1)]
    sg[br[0][0]]=1
    sg[br[0][1]]=1
    gn=1
    fubensa.append(fubensa[0]-1)

    for bri in range(1,bn-1):
        si1=br[bri][0]
        si2=br[bri][1]
        sg1=sg[si1]
        sg2=sg[si2]
        if sg1+sg2==0:
            gn+=1
            sg[si1],sg[si2]=gn,gn
            fubensa.append(fubensa[bri]-1)
        elif sg1==0:
            fubensa.append(fubensa[bri] - sg.count(sg2))
            sg[si1]=sg2
        elif sg2==0:
            fubensa.append(fubensa[bri] - sg.count(sg1))
            sg[si2]=sg1
        elif sg1!=sg2:
            sg1c=sg.count(sg1)
            sg2c=sg.count(sg2)
            if sg1c<sg2c:
                sg1,sg2=sg2,sg1
            fubensa.append(fubensa[bri] - sg1c*sg2c)
            sg=[sg1 if x==sg2 else x for x in sg]
        else:
            fubensa.append(fubensa[bri])
for x in fubensa[::-1]:
    print(x)

### FIXED CODE ###

sn,bn=map(int,input().split(" "))
fu=[int(sn*(sn-1)/2)]
gr_si=[n for n in range(sn+1)]
siL_gr=[[n] for n in range(sn+1)]
siL_br=[]
for _ in range(bn):
    siL_br.append(list(map(int, input().split(" "))))
siL_br=siL_br[::-1]

for bri in range(bn-1):
    si1,si2=siL_br[bri]
    gr1 = gr_si[si1]
    gr2 = gr_si[si2]
    if gr1==gr2:
        fu.append(fu[bri])
    else:
        lengr1 = len(siL_gr[gr1])
        lengr2 = len(siL_gr[gr2])
        if lengr1<lengr2:
            gr1,gr2=gr2,gr1
        fu.append(fu[bri]-lengr1*lengr2)
        for si in siL_gr[gr2]:
            gr_si[si]=gr1
        siL_gr[gr1]+=siL_gr[gr2]
        siL_gr[gr2]=[]

print(*fu[::-1],sep="\n")