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

n, *a = map(int, open(0).read().split())
MOD = 10**9 + 7
c = 0
for i in range(61):
  i = 2**i
  t = sum(i & b > 0 for b in a)
  c = (c + t * (n - t) * i) % MOD
print(c)

### FIXED CODE ###

n, *a = map(int, open(0).read().split())
MOD = 10**9 + 7
c = 0
for i in range(61):
  i = 2**i
  t = sum(i & b and 1 for b in a)
  c = (c + t * (n - t) * i) % MOD
print(c)
### BUGGY CODE ###

def onlya(n , a):

    ans = "YES"

    for i in range(n):
        for w in range(i + 1 , n):
            if a[i] == a[w]:
                return "NO"

    return ans

def main():
    n = int(input())
    a = list(map(int,input().split()))
    print(onlya(n , a))

if __name__ == '__main__':
    main()

### FIXED CODE ###


def has_duplicates(seq):
    return len(seq) != len(set(seq))

def onlya(n , a):

    ans = "YES"

#    for i in range(n):
#        for w in range(i + 1 , n):
#            if a[i] == a[w]:
#                return "NO"

    if has_duplicates(a):
        return "NO"

    return ans

def main():
    n = int(input())
    a = list(map(int,input().split()))
    print(onlya(n , a))

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

L,R=map(int, input().strip().split())

d=2018
for i in range(R-L+1):
  a=L+i
  for j in range(R-a):
    b=a+j+1
    c=(a*b)%2019
    if c<d:
      d=c
print(d)

### FIXED CODE ###

L,R=map(int, input().strip().split())

d=2018
for i in range(min(R-L,2019)):
  a=L+i
  for j in range(min(R-a,2019)):
    b=a+j+1
    c=(a*b)%2019
    if c<d:
      d=c
print(d)
### BUGGY CODE ###

from collections import defaultdict
from collections import deque

n, m = map(lambda x: int(x), input().split())
person_to_friends = defaultdict(set)

for _ in range(m):
    a, b = map(lambda x: int(x), input().split())
    person_to_friends[a].add(b)
    person_to_friends[b].add(a)

not_searched = set(range(1, n+1))
max_pool_num = 1

while len(not_searched) > 0:
#     print(not_searched)
    first_person = not_searched.pop()
    friend_pool = set([first_person])
    que = deque([first_person])
    while len(que) > 0:
        current_person = que.pop()
#         print('que', que)
        not_searched_friends = person_to_friends[current_person].intersection(not_searched)
#         print(not_searched_friends)
        for friend in not_searched_friends:
            not_searched.remove(friend)
            que.appendleft(friend)
            friend_pool.add(friend)
    max_pool_num = max(len(friend_pool), max_pool_num)
print(max_pool_num)

### FIXED CODE ###

# UnionFind

# 配列で、子のID番目:(親のID), 親のID番目:(その塊の-サイズ)
# Union Findを使う
class UnionFind:
    def __init__(self, size):
        self.parent_indexes = [-1] * size
        
    def find_parent(self, n):
#         print(self.parent_indexes[n])
        if self.parent_indexes[n] < 0:
            return n
#         print('hewe')
        # 探しているnodeが指し示しているのが現在の親ではない場合、
        # 現在の親に書き換え(memo化)た上で返す
        self.parent_indexes[n] = self.find_parent(self.parent_indexes[n])
        return self.parent_indexes[n] 
    
    def union(self, n1, n2):
        if self.same_group(n1, n2):
            return False
        
        # サイズの大きい方の親が親であり続ける
        if self.size(n1) >= self.size(n2):
            tmp = self.size(n2)
            self.parent_indexes[self.find_parent(n2)] = self.find_parent(n1)
            self.parent_indexes[self.find_parent(n1)] -= tmp
            return True
        
        tmp = self.size(n1)
        self.parent_indexes[self.find_parent(n1)] = self.find_parent(n2)
        self.parent_indexes[self.find_parent(n2)] -= tmp
        return True
        
    
    def size(self, n):
        return -self.parent_indexes[self.find_parent(n)]
    
    def same_group(self, n1, n2):
        return self.find_parent(n1) == self.find_parent(n2)



n, m = map(lambda x: int(x), input().split())
uf = UnionFind(n)

for _ in range(m):
    a, b = map(lambda x: int(x), input().split())
    uf.union(a-1, b-1)
    
print(-min(uf.parent_indexes))
### BUGGY CODE ###

from collections import deque
h,w = map(int,input().split())
mz = []
q = deque()
for i in range(h):
    mz.append(list(input()))
    ls = [[i,j,0] for j, a in enumerate(mz[-1]) if a == '#'] #i黒のところのindexをqueに追加
    q.extend(ls)


delta = [[-1,0],[0,-1],[1,0],[0,1]]
while q:
    y,x,c = q.popleft()
    for dy,dx in delta:
        if (0<= y+dy <h) and (0<=x+dx <w):
            if mz[y+dy][x+dx] == ".":
                mz[y+dy][x+dx]="#" #黒に置き換え
                q.append([y+dy,x+dx,c+1])

            else: #すでに黒なら訪問しなくてよい
                pass

print(c)#cは最後にpopされたcost


### FIXED CODE ###

from collections import deque
h,w = map(int,input().split())
mz = []
q = deque()
for i in range(h):
    mz.append(list(input()))
    ls = [[i,j,0] for j, a in enumerate(mz[-1]) if a == '#'] #i黒のところのindexをqueに追加
    q.extend(ls)


delta = [[-1,0],[0,-1],[1,0],[0,1]]
while q:
    y,x,c = q.popleft()
    for dy,dx in delta:
        if (0<= y+dy <h) and (0<=x+dx <w):
            if mz[y+dy][x+dx] == ".":
                mz[y+dy][x+dx]="#" #黒に置き換え
                q.append([y+dy,x+dx,c+1])

            else: #すでに黒なら訪問しなくてよい
                pass

print(c)#cは最後にpopされたcost
### BUGGY CODE ###

N,M = map(int,input().split())
A = [[] for i in range(N)]
checkd = [False]*N
for _ in range(M):
    a,b = (map(lambda a: int(a)-1, input().split()))
    A[a].append(b)
    A[b].append(a)
nextS = set(range(N))
ans = 0
while len(nextS)>0:
    s = nextS.pop()
    if checkd[s]: 
        continue
    count = 0
    que = [s]
    while len(que)>0:
        nn = que.pop(0)
        if checkd[nn]:
            continue
        checkd[nn] = True
        nextS.discard(nn)
        count += 1
        que += A[nn]
    ans = max(count,ans)


print(ans)




### FIXED CODE ###

from collections import deque

N,M = map(int,input().split())
A = [[] for i in range(N)]
checkd = [False]*N
for _ in range(M):
    a,b = (map(lambda a: int(a)-1, input().split()))
    A[a].append(b)
    A[b].append(a)
nextS = set(range(N))
ans = 0
while len(nextS)>0:
    s = nextS.pop()
    if checkd[s]: 
        continue
    count = 0
    que = deque([s])
    while len(que)>0:
        nn = que.popleft()
        if checkd[nn]:
            continue
        checkd[nn] = True
        nextS.discard(nn)
        count += 1
        que.extend(A[nn])
    ans = max(count,ans)


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

N, *L = map(int, open(0).read().split())
cost = []
for i, m in enumerate(zip(*[iter(L)]*N)):
  cost.append(m)
ans = 0
for i in range(N):
  for j in range(i):
    m = min(cost[i][k]+cost[k][j] if k!=i and k!=j else 10**10 for k in range(N))
    if m<cost[i][j]:
      print(-1)
      import sys
      sys.exit()
    if m!=cost[i][j]:
      ans += cost[i][j]
print(ans)

### FIXED CODE ###

from collections import defaultdict
N = int(input())
cost = [[0]*N for i in range(N)]
dist = [[0]*N for i in range(N)]
log = defaultdict(int)
for i in range(N):
  inf = [int(c) for c in input().split()]
  for j in range(N):
    cost[i][j] = inf[j]
for i in range(N):
  for j in range(i+1,N):
    m = float('inf')
    for k in range(N):
      if cost[i][j]>=cost[i][k]+cost[k][j]:
        m = min(m,cost[i][k]+cost[k][j])
        if k != i and k!= j:
          log[(min(i,j),max(i,j))] = 1
    dist[i][j] = m
    dist[j][i] = m
ans = 0
for i in range(N):
  for j in range(i+1,N):
    flag = False
    if dist[i][j]<cost[i][j]:
      print(-1)
      flag = True
      break
    elif log[(i,j)]==0:
      ans += cost[i][j]
  if flag:
    break
else:
  print(ans)
### BUGGY CODE ###

N = int(input())
S = input()


def isok(n):
    for i in range(N-2*n+1):
        now = S[i:i+n]
        if S[i+n:].find(now) != -1:
            return True
    return False


left = 0
right = N//2+1

while right - left > 1:
    mid = left + (right-left)//2
    if not isok(mid):
        right = mid
    else:
        left = mid

print(left)


### FIXED CODE ###

N = int(input())
S = input()


r = 1
ans = 0
for l in range(N):

    while True:
        #print(S.rfind(S[l:r+1]), S[l:r+1], l, r)

        if S.rfind(S[l:r+1]) >= r+1:
            r += 1
            ans = max(ans, r-l)
        else:
            break

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

from collections import deque
 
H, W = map(int, input().split())
 
init_field = [list(input()) for _ in range(H)]
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
 
def bfs(x, y):
    distance = [[-1]*W for _ in range(H)]
    que = deque([])
    que.append((y, x))
    distance[y][x] = 0
    while que:
        y, x = que.popleft()
        if x == gx and y == gy:
            break
        for i, j in zip(dx, dy):
            nx = x + i
            ny = y + j
            if 0 <= nx < W and 0 <= ny < H and field[ny][nx] == "." and distance[ny][nx] == -1:
                distance[ny][nx] = distance[y][x] + 1
                que.append((ny, nx))
    return distance

ans = 0
for sy in range(H):
    for sx in range(W):
        if init_field[sy][sx] == '#':
            continue
        for gy in range(H):
            for gx in range(W):
                if init_field[gy][gx] == "#":
                    continue
                field = [[i for i in row] for row in init_field]
                if sx == gx and sy == gy:
                    continue
                d = bfs(sx, sy)
                ans = max(ans, d[gy][gx])
print(ans)


### FIXED CODE ###

from collections import deque
 
H, W = map(int, input().split())
 
init_field = [list(input()) for _ in range(H)]
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
 
def bfs(x, y):
    distance = [[-1]*W for _ in range(H)]
    que = deque([])
    que.append((y, x))
    distance[y][x] = 0
    res = 0
    while que:
        y, x = que.popleft()
        res = max(res, distance[y][x])
        for i, j in zip(dx, dy):
            nx = x + i
            ny = y + j
            if 0 <= nx < W and 0 <= ny < H and field[ny][nx] == "." and distance[ny][nx] == -1:
                distance[ny][nx] = distance[y][x] + 1
                que.append((ny, nx))
    return res

ans = 0
for sy in range(H):
    for sx in range(W):
        if init_field[sy][sx] == '#':
            continue
        field = [[i for i in row] for row in init_field]
        d = bfs(sx, sy)
        ans = max(ans, d)
print(ans)
### BUGGY CODE ###

# coding: utf-8
# Your code here!
def main():
    def gcd(a, b):
        while b:
            a, b = b, a % b
        return a
    
    def is_prime(n):
        if n == 1:
            return True
        for i in range(2,int(n**0.5)+1):
            if n % i == 0:
                return False
        return True
    
    a,b=map(int,input().split())
    c=gcd(a,b)
    cnt=0
    for i in range(1,c+1):
        if a%i==0 and b%i==0:
            if is_prime(i):
                cnt+=1
                
            
    print(cnt)
    
    
if __name__ == "__main__":
    main()


### FIXED CODE ###

# coding: utf-8
# Your code here!
def main():
    def gcd(a, b):
        while b:
            a, b = b, a % b
        return a
    
    def divisor(n):
        ass = []
        for i in range(1,int(n**0.5)+1):
            if n%i == 0:
                ass.append(i)
                if i**2 == n:
                    continue
                ass.append(n//i)
        return ass
    
    def is_prime(n):
        if n == 1:
            return True
        for i in range(2,int(n**0.5)+1):
            if n % i == 0:
                return False
        return True
    
    a,b=map(int,input().split())
    c=gcd(a,b)
    cnt=0
    d=divisor(c)
    for i in d:
        if is_prime(i):
            cnt+=1
    print(cnt)
    
if __name__ == "__main__":
    main()
### BUGGY CODE ###

import itertools

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

s = [0]
for i in range(n):
    s.append(s[i] + ai[i])

cnt = 0
for sj, si in itertools.combinations(s, 2):
    if si - sj == 0:
        cnt += 1

print(cnt)

### FIXED CODE ###

import collections
import math


def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


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

s = [0]
for i in range(n):
    s.append(s[i] + ai[i])

c = collections.Counter(s)
print(sum([comb(v, 2) if v > 1 else 0 for v in c.values()]))
### BUGGY CODE ###

N = int(input())
L = [[int(x) for x in input().split()] for _ in range(N-1)]

dic = {}
visited = [0]*(N+1)
for i in range(N-1):
    if visited[L[i][0]] == 1:
        dic[L[i][0]].append([L[i][1], L[i][2]])
    else:
        dic[L[i][0]] = [[L[i][1], L[i][2]]]
        visited[L[i][0]] = 1
    if visited[L[i][1]] == 1:
        dic[L[i][1]].append([L[i][0], L[i][2]])
    else:
        dic[L[i][1]] = [[L[i][0], L[i][2]]]
        visited[L[i][1]] = 1

ans_list = ["0"]*(N+1)
q = [[1, 0]]
visited = [0]*(N+1)
while len(q) > 0:
    t = q.pop(0)
    v = t[0]
    d = t[1]
    for i in range(len(dic[v])):
        if visited[dic[v][i][0]] == 0:
            q.append([dic[v][i][0], d+dic[v][i][1]])
            visited[dic[v][i][0]] = 1
            if (d+dic[v][i][1])%2 == 1:
                ans_list[dic[v][i][0]] = "1"
                
for i in range(1, N+1):
    print(ans_list[i])

### FIXED CODE ###

from collections import deque

N = int(input())
edge = [[] for _ in range(N)]
for _ in range(N-1):
    u, v, w = map(int, input().split())
    edge[u-1].append([v-1, w])
    edge[v-1].append([u-1, w])
    
d = [0]*(N)

q = deque()
q.append([0, 0])
visited = [0]*(N)
while q:
    temp = q.pop()
    for L in edge[temp[0]]:
        if visited[L[0]] == 0:
            d[L[0]] = L[1] + temp[1]
            q.append([L[0], d[L[0]]])
            visited[L[0]] = 1
            
for i in range(N):
    print(d[i]%2)
### BUGGY CODE ###

#def solve():
INF = float('inf')

def max2(x, y): return x if x >= y else y

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

As.sort(reverse=True)

dp = [[-INF]*(N+1) for _ in range(N+1)]
dp[0][0] = 0
for no, (A, pos) in enumerate(As):
    for i in range(no+1):
        j = no-i
        dp[i+1][j] = max2(dp[i+1][j], dp[i][j] + A*abs(pos-i))
        dp[i][j+1] = max2(dp[i][j+1], dp[i][j] + A*abs(pos-(N-1-j)))

ans = 0
for i in range(N+1):
    j = N-i
    ans = max2(ans, dp[i][j])

print(ans)
 
 
#solve()

### FIXED CODE ###

def solve():
    INF = float('inf')
 
    def max2(x, y): return x if x >= y else y
 
    N = int(input())
    As = [(A, i) for i, A in enumerate(map(int, input().split()))]
 
    As.sort(reverse=True)
 
    dp = [[-INF]*(N+1) for _ in range(N+1)]
    dp[0][0] = 0
    for no, (A, pos) in enumerate(As):
        for i in range(no+1):
            j = no-i
            dp[i+1][j] = max2(dp[i+1][j], dp[i][j] + A*abs(pos-i))
            dp[i][j+1] = max2(dp[i][j+1], dp[i][j] + A*abs(pos-(N-1-j)))
 
    ans = 0
    for i in range(N+1):
        j = N-i
        ans = max2(ans, dp[i][j])
 
    print(ans)
 
 
solve()
### BUGGY CODE ###

N,T = map(int,input().split())
A=[int(x) for x in input().split()]
s=[]
count=0
for i in range(1,N):
  s += [A[i]-min(A[0:i])]
for j in range(len(s)):
  if s[j]==max(s):
    count +=1
print(count)

### FIXED CODE ###

import numpy as np
N,T = map(int,input().split())
A=np.array(input().split(),dtype=np.int32)
s=A-np.minimum.accumulate(A)
print((s==max(s)).sum())
### BUGGY CODE ###

N, K = map(int, input().split())
[*h] = map(int, input().split())
dp = [float('inf') for _ in range(N)]
dp[0] = 0
for i in range(N):
  for j in range(1, min(i, K)+1):
    dp[i] = min(dp[i], dp[i-j]+abs(h[i]-h[i-j]))

print(dp[N-1])

### FIXED CODE ###

import numpy as np
N, K = map(int, input().split())
h = np.array(list(map(int, input().split())))
dp = np.zeros(N, dtype=int)
for i in range(1, N):
  j = max(0, i-K)
  dp[i] = np.min(dp[j:i]+np.abs(h[i]-h[j:i]))
                 
print(dp[N-1])
### BUGGY CODE ###

def resolve():
    n,q = map(int, input().split())
    s = input()
    num = [0]*n
    for i in range(n):
        if i > 0:
            if s[i-1] == "A" and s[i] == "C":
                num[i-1] = 1
                num[i] = 1
    for i in range(q):
        l,r = map(int, input().split())
        test = sum(num[l-1: r])
        if (l-1) != 0:
            if s[l-1] != "A":
                test -= 1
        if r != n:
            if s[r-1] != "C":
                test -= 1
        print(test//2)
resolve()

### FIXED CODE ###

def resolve():
    n,q = map(int, input().split())
    s = input()
    num = [0]*n
    k = 0
    for i in range(n):
        if i > 0:
            if s[i-1] == "A" and s[i] == "C":
                k += 1
            num[i] = k
    for i in range(q):
        l,r = map(int, input().split())
        test = num[r-1]-num[l-1]
        print(test)
resolve()
### BUGGY CODE ###

N = int(input())
S = input()
L_r = []
L_g = []
L_b = []
ans = 0
for i in range(N):
    if S[i] == "R":
        L_r.append(i)
    elif S[i] == "G":
        L_g.append(i)
    else:
        L_b.append(i)
m = min(len(L_r),len(L_g),len(L_b))
if len(L_r) == m:
    for x in L_g:
        for y in L_b:
            ans += m
            if 2*x - y in L_r:
                ans -= 1
            if 2*y - x in L_r:
                ans -= 1
            if (x + y) % 2 == 0 and (x + y) // 2 in L_r:
                ans -= 1
elif len(L_g) == m:
    for x in L_r:
        for y in L_b:
            ans += m
            if 2*x - y in L_g:
                ans -= 1
            if 2*y - x in L_g:
                ans -= 1
            if (x + y) % 2 == 0 and (x + y) // 2 in L_g:
                ans -= 1
else:
    for x in L_r:
        for y in L_g:
            ans += m
            if 2*x - y in L_b:
                ans -= 1
            if 2*y - x in L_b:
                ans -= 1
            if (x + y) % 2 == 0 and (x + y) // 2 in L_b:
                ans -= 1
print(ans)

### FIXED CODE ###

N = int(input())
S = list(input())
ans = 0
r = S.count("R")
g = S.count("G")
b = S.count("B")
ans += r*g*b
m = 0
if N >= 3:
  for i in range(N-2):
    for j in range(i+1,N-1):
      k = 2*j-i
      if  k < N and S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
        m += 1
print(ans-m)
### BUGGY CODE ###

import sys
from collections import deque
n,m = map(int, sys.stdin.readline().rstrip("\n").split())
edge = [[] for i in range(n)]
for i in range(m):
    a,b = map(int, sys.stdin.readline().rstrip("\n").split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)
footprint = [10**9+7]*n
q = deque()
footprint[0] = 0
for i in edge[0]:
    q.append((i,0))
while q:
    nn,fn = q.popleft()
    if footprint[nn] == 10**9+7:
        footprint[nn] = fn
    for i in edge[nn]:
        if footprint[i] == 10**9+7:
            q.append((i,nn))
if 10**9+7 in footprint:
    print('No')
else:
    print('Yes')
    for i in range(1,n):
        print(footprint[i]+1)

### FIXED CODE ###

import sys
import queue
n,m = map(int, sys.stdin.readline().rstrip("\n").split())
adj = [[]for i in range(n+1)]
parent = [-1] * (n+1)
for line in sys.stdin:
    a,b = map(int, line.rstrip("\n").split())
    adj[a].append(b)
    adj[b].append(a)
q = queue.Queue()
q.put((1,0))
while(not q.empty()):
    x, p = q.get()
    if parent[x] != -1: # 訪問済み
        continue
    parent[x] = p
    for next in adj[x]:
        if parent[next] == -1: # 未訪問なら
            q.put((next,x))
print ('Yes') # 必ず目標は達成できる
for p in parent[2:]: # 部屋2以降の親（前の部屋）
    print(p)
### BUGGY CODE ###

import bisect
import sys

input = sys.stdin.readline


def read_i():
    return list(map(int, input().split()))


n = int(input())
ls = sorted(read_i())
ls2 = ls[::-1]
res = 0
for i, x in enumerate(ls2):
    for j, y in enumerate(ls2[i + 1:], i + 1):
        res += n - j - 1 - bisect.bisect(ls[:-(j + 1)], x - y)
print(res)

### FIXED CODE ###

import bisect
import sys

input = sys.stdin.readline


def read_i():
    return list(map(int, input().split()))


n = int(input())
ls = sorted(read_i())
ls2 = ls[::-1]
res = 0
for i, x in enumerate(ls2):
    for j, y in enumerate(ls2[i + 1:], i + 1):
        if 2 * y < x:
            break
        res += n - j - 1 - bisect.bisect(ls[:-(j + 1)], x - y)
print(res)
### BUGGY CODE ###

N, K, Q = map(int, input().split())
A = [int(input()) for i in range(Q)]
hit = [0]*N
poi = [K]*N
for i in range(N):
    hit[i] = A.count(i+1)
    poi[i] = K - Q + hit[i]
    if poi[i] > 0:  print('Yes')
    else:           print('No')
      

### FIXED CODE ###

N, K, Q = map(int, input().split())
A = [int(input()) for i in range(Q)]
poi = [K-Q]*N
for i in range(Q):
    poi[A[i]-1] += 1

for i in range(N):
    if poi[i] > 0:  print('Yes')
    else:           print('No')
### BUGGY CODE ###

"""
最大公約数を最も落とす原因になっている整数を特定したい。
"""
from collections import Counter

N = int(input())
A = list(map(int,input().split()))
count = Counter([])

for a in A:
    tmp = []
    d = 1
    while d*d < a:
        if a%d == 0:
            tmp.append(d)
            tmp.append(a//d)
        d += 1
    if d**2 == a:
        tmp.append(d)
    count += Counter(tmp)

ans = 0
for k,v in count.items():
    if v >= N-1:
        ans = max(ans,k)
print(ans)


### FIXED CODE ###

"""
問題文を言い換えると、「最大公約数が最大になるように数字を一つ書き換えろ」ということ。
さらに言い換えると、「最大公約数が最大になるように数字を一つ消せ」ということ。
単純な線形探索でできるか？→NO

最大公約数を小さくする要因となっている数字を一つ消す。
どういう数字が最大公約数を小さくする要因になっているか？
他の数字と共通する素因数が少ない、小さい、次数が小さい。ただ、この3つを総合的に判断するのは難しすぎる。
素因数分解はやめて、単純に約数で探せばよいか。
各Aの約数を昇順で列挙しておく。
まずA1は必ず残すと仮定して、A1の約数の大きい方から順番に、ほかのAの約数になるかどうかを調べる。
その約数を含んでいないAが一つだけ存在するとき、そのAを消せば、その約数が最大公約数となる。

次に、A1を消す場合の最大公約数も求めて、A1を含める場合の最大公約数と比較して大きい方を採用する。
"""

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

#A1を必ず入れる場合の最大公約数を求める。
yakusu = []

a = A[0]
d = 1
while d*d < a:
    if a % d == 0:
        yakusu.append(d)
        yakusu.append(a//d)
    d += 1
if d*d == a:
    yakusu.append(d)
yakusu.sort(reverse=True)

ans = 1
for v in yakusu:
    cnt = 0
    for i in range(1,N):
        if A[i]%v != 0:
            cnt += 1
    if cnt <= 1:
        ans = v
        break

#A1を入れない場合の最大公約数を求める。
import math
g = A[1]
for i in range(2,N):
    g = math.gcd(g,A[i])

ans = max(ans,g)

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

s = input()
K = int(input())

substringList = []
if(len(s) < 10):
    for i in range(len(s)):
            for j in range(i, len(s)):
                #print(i,j)
                if(s[i:j+1] in substringList):
                    pass
                else:
                    substringList.append(s[i:j+1])
else:
    for i in range(len(s)):
            for j in range(i, i+6):
                #print(i,j)
                if(s[i:j+1] in substringList):
                    pass
                else:
                    substringList.append(s[i:j+1])
#substringList = list(set(substringList))
print(sorted(substringList)[K-1])


### FIXED CODE ###

s = input()
K = int(input())

substringList = []
if(len(s) < 50):
    for i in range(len(s)):
            for j in range(i, len(s)):
                #print(i,j)
                if(s[i:j+1] in substringList):
                    pass
                else:
                    substringList.append(s[i:j+1])
else:
    for i in range(len(s)):
            for j in range(i, i+5):
                substringList.append(s[i:j+1])
#substringList = list(set(substringList))
print(sorted(list(set(substringList)))[K-1])
### BUGGY CODE ###

from collections import deque, defaultdict

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

# 現在末尾に追加される山より若い山で，最も個数の大きいものが次の山になる
# 他の山を次の山の個数以下まで減らす

nextNumIndex = deque([0])

for i, a in enumerate(A[1:], start=1):
    if a > A[nextNumIndex[-1]]:
        nextNumIndex.append(i)

V = set()  # 大きい山
W = set(range(N))  # 小さい山
ansList = defaultdict(int)

while len(nextNumIndex) > 1:
    nowIndex = nextNumIndex.pop()
    nextIndex = nextNumIndex[-1]

    newW = set()
    cnt = len(V) * (A[nowIndex] - A[nextIndex])
    for w in W:
        if A[w] >= A[nextIndex]:
            V.add(w)
            cnt += A[w] - A[nextIndex]
        else:
            newW.add(w)
    W = newW
    ansList[nowIndex] = cnt

    if len(nextNumIndex) == 1:
        for i in range(N):
            A[i] = min(A[i], A[nextIndex])

ansList[0] = sum(A)

ans = []
for i in range(N):
    ans.append(ansList[i])

print(*ans, sep='\n')

### FIXED CODE ###

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

# 現在末尾に追加される山より若い山で，最も個数の大きいものが次の山になる
# 他の山を次の山の個数以下まで減らす

ans = [0] * N

numList = [(a, i) for i, a in enumerate(A)]
numList.sort(reverse=True)
numList.append((0, 0))

y = float('inf')
for c, (a, i) in enumerate(numList[: N], start=1):
    y = min(y, i)
    ans[y] += c * (a - numList[c][0])

print(*ans, sep='\n')