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

n = int(input())
a = list(map(int, input().split()))
a.sort()
if a[0]==1:
    if n==1 or a[1]>1:
        print(1)
    else:
        print(0)
    exit(0)
seen = []
same = set()
ans = 0
pre = -1
flg = False
for i in a:
    if i==pre:
        if flg:
            same.add(i)
        continue
    pre = i
    flg = True
    for j in seen:
        if j*2>i:
            break
        if i%j==0:
            flg = False
            break
    if flg:
        ans += 1
        seen.append(i)
print(ans-len(same))

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
a.sort()
if a[0]==1:
    if n==1 or a[1]>1:
        print(1)
    else:
        print(0)
    exit(0)
ok = [True]*(10**6+1)
ans = 0
pre = -1
for i in a:
    if not ok[i]:
        continue
    if i==pre:
        ok[i] = False
        continue
    pre = i
    for j in range(i*2, 10**6+1, i):
        ok[j] = False
for i in a:
    if ok[i]:
        ans += 1
print(ans)
### BUGGY CODE ###

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

false_flag = 0
if N % 2 == 0:
    count_ = 1
else:
    if A.count(0) != 1:
        false_flag = 1
    count_ = 2
while count_ < N and false_flag == 0:
    if A.count(count_) != 2:
        false_flag = 1
    count_ += 2

if false_flag == 0:
    print(2 ** (N // 2))
else:
    print(0)

### FIXED CODE ###

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

false_flag = 0
'''
if N % 2 == 0:
    count_ = 1
else:
    if A.count(0) != 1:
        false_flag = 1
    count_ = 2
while count_ < N and false_flag == 0:
    if A.count(count_) != 2:
        false_flag = 1
    count_ += 2
'''

count_list = [0 for i in range(N)]
for index in A:
    count_list[index] += 1

if N % 2 == 0:
    count_ = 1
    diff = -1
else:
    if count_list[0] != 1:
        false_flag = 1
    count_ = 2
    diff = -1
while count_ < N and false_flag == 0:
    #print(count_)
    if count_list[count_] != 2 or count_list[count_ + diff] != 0:
        false_flag = 1
    count_ += 2

if false_flag == 0:
    print((2 ** (N // 2) ) % 1000000007)
else:
    print(0)
### BUGGY CODE ###

from operator import mul
from functools import reduce

# def c(n, r):
#     r = min(r, n - r)
#     numer = reduce(mul, range(n, n - r, -1), 1)
#     denom = reduce(mul, range(1, r + 1), 1)
#     return numer // denom
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

cnt = 0
s = []
tmp = []
n = int(input())
for i in range(n):
    string = input()
    string = ''.join(sorted(string))
    s.append(string)

for i, e in enumerate(s):
    """
    要素が何個あるか検査　AND　tmpにないやつ
    ・１：なにもしない
    ・2以上：個数調べてCNT更新。その要素をtmpに記録する
    """
    count = s.count(e)
    if count > 1 and not e in tmp:
        cnt += cmb(count, 2)
        tmp.append(e)
print(cnt)

### FIXED CODE ###

import collections

cnt = 0
s = []
tmp = []
n = int(input())
for i in range(n):
    string = input()
    string = ''.join(sorted(string))
    s.append(string)

# for i, e in enumerate(s):
#     count = s.count(e)
#     if count > 1 and not e in tmp:
#         cnt += count*(count-1)//2
#         tmp.append(e)
cc = collections.Counter(s)

for cv in cc.values():
    if cv > 1:
        cnt += cv*(cv-1)//2

print(cnt)
### BUGGY CODE ###

import math
import os
import sys
from collections import defaultdict
from functools import lru_cache

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18

MOD = 10 ** 9 + 7
N, K = list(map(int, sys.stdin.readline().split()))


@lru_cache(maxsize=None)
def next_max(n):
    # ある数と隣り合わせになれる数
    return int(N // n)


NM = []
prev = 0
for i in range(1, int(math.sqrt(N)) + 2):
    NM.append(N - next_max(i) - prev)
    prev = (N - next_max(i))


@lru_cache(maxsize=None)
def rec(n, k):
    if n <= 0:
        return 0
    if k <= 1:
        return n

    i = next_max(n)
    p = NM[i] if i < len(NM) else 1
    ret = rec(i, k - 1) * p % MOD
    cum = rec(n - p, k)
    return (cum + ret) % MOD


cnt = N
nums = []
while cnt >= 1:
    nums.append(cnt)
    i = next_max(cnt)
    p = NM[i] if i < len(NM) else 1
    cnt -= p
nums.reverse()

# dp[k][n]: rec(n, k)
dp = defaultdict(lambda: defaultdict(int))
for n in nums:
    dp[1][n] = n
for k in range(2, K+1):
    for n in nums:
        i = next_max(n)
        p = NM[i] if i < len(NM) else 1
        ret = dp[k - 1][i] * p % MOD
        cum = dp[k][n - p]
        dp[k][n] = (cum + ret) % MOD

ans = dp[K][N]
print(ans % MOD)

# ans = rec(N, K)
# print(ans % MOD)


### FIXED CODE ###

import math
import os
import sys
from collections import defaultdict

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18

MOD = 10 ** 9 + 7
N, K = list(map(int, sys.stdin.readline().split()))

NM = []
prev = 0
for i in range(1, int(math.sqrt(N)) + 2):
    m = int(N // i)
    NM.append(N - m - prev)
    prev = N - m

cnt = N
nums = []
while cnt >= 1:
    nums.append(cnt)
    i = int(N // cnt)
    p = NM[i] if i < len(NM) else 1
    cnt -= p
nums.reverse()

# dp[k][n]: rec(n, k)
dp = defaultdict(lambda: defaultdict(int))
for n in nums:
    dp[1][n] = n
for k in range(2, K + 1):
    for n in nums:
        i = int(N // n)
        p = NM[i] if i < len(NM) else 1
        ret = dp[k - 1][i] * p % MOD
        cum = dp[k][n - p]
        dp[k][n] = (cum + ret) % MOD

ans = dp[K][N]
print(ans % MOD)

# ans = rec(N, K)
# print(ans % MOD)
### BUGGY CODE ###

# 初期入力
import sys
input = sys.stdin.readline  #文字列では使わない
N,K = map(int, input().split())
#Kの倍数（２N以下）⓵
multip_K =[i for i in range(0,2*N+1,K)]
#multip_K =multip[K::K]

#2数の和が上記⓵ ⇒a,bの候補探す
from collections import defaultdict
ad =defaultdict(list)
ad_set =set()
for i in multip_K:
    for j in range(1,N+1):
        if 0 < i-j <=N:
            ad[i].append((j,i-j))
            ad_set.add((j,i-j))

#cを探す
count =0

for i in range(1,N+1):
    for ab in ad.values():
        for abc in ab:
            if (abc[0],i) in ad_set and (abc[1],i) in ad_set:
                count +=1

print(count)

### FIXED CODE ###

#プログラミング日記   一寸先は闇が人生
# https://pyteyon.hatenablog.com/entry/2018/09/02/094228
# 初期入力
import sys
input = sys.stdin.readline  #文字列では使わない
N,K = map(int, input().split())

# 偶数、奇数共に
# a,b,c mod 0,0,0 ⇒Kの倍数
multip_K =[i for i in range(K,N+1,K)]

#multip_Kから３つ選び並べる順列組み合わせ
le =len(multip_K)
ans_mod_0 =le **3

# 偶数のみ
# a,b,c mod K/2,K/2,K/2 
ans_mod_haf =0
if K%2 ==0:
    multip_haf =[i for i in range(1,N+1) if i %K ==K//2 ]
    le_haf =len(multip_haf)
    ans_mod_haf =le_haf **3

ans =ans_mod_0 +ans_mod_haf
print(ans)
### BUGGY CODE ###

import bisect

n,m = map(int,input().split())
a = list(map(int,input().split()))
s = []
for i in range(m):
    b,c = map(int,input().split())
    s.append((c,b))

a.sort()
s.sort(reverse=True)

for i in range(m):
    b = s[i][1]
    c = s[i][0]
    idx = bisect.bisect_left(a,c)
    if idx == 0:
        break
    del a[0:min(b,idx)]
    for j in range(min(b,idx)):
        a.insert(bisect.bisect_left(a,c),c)

print(sum(a))
    

### FIXED CODE ###

import bisect

n,m = map(int,input().split())
a = list(map(int,input().split()))
s = []
for i in range(m):
    b,c = map(int,input().split())
    s.append((c,b))

a.sort()
s.sort(reverse=True)

for i in range(m):
    b = s[i][1]
    c = s[i][0]
    idx = bisect.bisect_left(a,c)
    if idx == 0:
        break
    del a[0:min(b,idx)]
    for j in range(min(b,idx)):
        a.insert(bisect.bisect_left(a,c),c)

print(sum(a))
### BUGGY CODE ###

import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**9)
from collections import deque
from math import ceil

def dist(h,w,x,y):
    return min(x-1,h-x,y-1,w-y)

h,w,k=map(int,input().split())
MAP=[]
A=['#']*(w+2)
MAP.append(A)
for i in range(h):
    s='#'+input().strip()+'#'
    for j,t in enumerate(s):
        if t=='S':
            sx,sy=i+1,j
    MAP.append(list(s))
MAP.append(A)
delta=[[1,0],[0,1],[-1,0],[0,-1]]
P=[]
Visited=[[False]*(w+2) for _ in range(h+2)]
Visited[sx][sy]=True
q=deque()
q.append((sx,sy,k))
while q:
    x,y,t=q.popleft()
    if t<0:
        break
    P.append([x,y])
    t-=1
    for dx,dy in delta:
        if MAP[x+dx][y+dy]=='.' and not Visited[x+dx][y+dy]:
            q.append((x+dx,y+dy,t))
            Visited[x+dx][y+dy]=True
ans=float('inf')
for x,y in P:
    ans=min(ans,1+ceil(dist(h,w,x,y)/k))
print(ans)

### FIXED CODE ###

import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**9)
from collections import deque
from math import ceil

h,w,k=map(int,input().split())
MAP=[]
for i in range(h):
    s=list(input().strip())
    for j,t in enumerate(s):
        if t=='S':
            sx,sy=i,j
    MAP.append(s)
delta=[[1,0],[0,1],[-1,0],[0,-1]]
q=deque()
q.append((sx,sy,k))
dist=float('inf')
Visited=[[False]*w for _ in range(h)]
Visited[sx][sy]=True
while len(q)>0:
    x,y,t=q.popleft()
    dist=min(dist,x,y,h-1-x,w-1-y)
    if dist==0:
        break
    if t>0:
        t-=1
        for dx,dy in delta:
            if MAP[x+dx][y+dy]=='.' and not Visited[x+dx][y+dy]:
                q.append((x+dx,y+dy,t))
                Visited[x+dx][y+dy]=True
print(1+ceil(dist/k))
### BUGGY CODE ###

# coding: utf-8

n, m = map(int, input().split())
l = [int(n) for n in input().split()]

for j in range(m):
    i = l.index(max(l))
    l[i] = int(l[i]/2)
    if l[i] <= 0:
        l.remove(l[i])
        if len(l) == 0:
            break
        
print(sum(l))



### FIXED CODE ###

# coding: utf-8
import heapq

n, m = map(int, input().split())
l = [ -1 * int(n) for n in input().split()]

heapq.heapify(l)

for i in range(m):
    a = heapq.heappop(l) * (-1)
    a = int(a/2)
    if a != 0:
        heapq.heappush(l, a * (-1))
    if len(l) == 0:
        break
    
    
print(sum(l) * (-1))
### BUGGY CODE ###

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

# 以下カンニング
for _ in range( min( k, 42 ) ):
    b = [ 0 for _ in range( n ) ]

    for i in range( n ):
        l = max( 0, i - a[ i ] )
        r = min( n - 1, i + a[ i ] )
        b[ l ] += 1
        if r + 1 < n:
            b[ r + 1 ] -= 1

    for i in range( 1, n ):
        b[ i ] += b[ i - 1 ]

    a = copy.deepcopy( b )

print( " ".join( list( map( str, a ) ) ) )

### FIXED CODE ###

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

# 以下カンニング
for _ in range( min( k, 41 ) ): # 41 ~ log( 2 * 10 ** 5 )
    b = [ 0 ] * n

    for i in range( n ):
        l = max( 0, i - a[ i ] )
        r = min( n - 1, i + a[ i ] )
        b[ l ] += 1
        if r + 1 < n:
            b[ r + 1 ] -= 1

    for i in range( 1, n ):
        b[ i ] += b[ i - 1 ]

    a = b

print( " ".join( list( map( str, a ) ) ) )
### BUGGY CODE ###


def parse():
  H, W = map(int, input().split(" "))
  grid = []
  for y in range(H):
    grid.append(list(input()))
  return H, W, grid

def print_grid(grid):
  H = len(grid)
  print("grid:")
  for line in grid:
    for c in line:
      print(c, end="")
    print("")

def main():
  H, W, grid = parse()
  # print(H, W)
  # print_grid(grid)

  visited = [[W * H if grid[y][x] == "." else 0 for x in range(W)] for y in range(H)]
  # for y in range(H):
  #   visited.append([])
  #   for x in range(W):
  #     if grid[y][x] == ".":
  #       visited[y].append(H * W)
  #     else:
  #       visited[y].append(0)
    # print(visited[y])
  
  for y in range(H):  # ↓
    for x_right, x_left in zip(range(1, W), range(W - 2, -1, -1)):  # →，←
      visited[y][x_right] = min(visited[y][x_right - 1] + 1, visited[y][x_right])
      visited[y][x_left] = min(visited[y][x_left], visited[y][x_left + 1] + 1)

  for x in range(W):  # →
    for y_down, y_up in zip(range(1, H), range(H - 2, -1, -1)):  # ↓，↑
      visited[y_down][x] = min(visited[y_down - 1][x] + 1, visited[y_down][x])
      visited[y_up][x] = min(visited[y_up][x], visited[y_up + 1][x] + 1)
  
  max_len = 0
  for y in range(H):
    max_len = max_len if max_len > max(visited[y]) else max(visited[y])
  print(max_len)

if __name__ == "__main__":
  main()

### FIXED CODE ###


import numpy as np

def parse():
  H, W = map(int, input().split(" "))
  grid = [list(input()) for y in range(H)]
  return H, W, grid

def print_grid(grid):
  H = len(grid)
  print("grid:")
  for line in grid:
    for c in line:
      print(c, end="")
    print("")

def main():
  H, W, grid = parse()
  # print(H, W)
  # print_grid(grid)

  # visited = [[W * H if grid[y][x] == "." else 0 for x in range(W)] for y in range(H)]
  visited = np.zeros((H, W), int)
  for y in range(H):
    # visited.append([])
    for x in range(W):
      if grid[y][x] == ".":
        visited[y][x] = H * W

  for y in range(1, H):  # ↓
    # 要素ごとの処理
    # print(visited)
    visited[y][:] = np.minimum(visited[y][:], visited[y - 1][:] + 1)
    # print(visited)
    # input()
    # print(visited[y])
    # exit(0)

  for y in range(H - 2, -1, -1):
    visited[y, :] = np.minimum(visited[y, :], visited[y + 1][:] + 1)

  for x in range(1, W):
    visited[:, x] = np.minimum(visited[:, x], visited[:, x - 1] + 1)

  for x in range(W - 2, -1, -1):
    visited[:, x] = np.minimum(visited[:, x], visited[:, x + 1] + 1)

  # print(visited)
  # exit(0)

  # max_len = 0
  # for y in range(H):
  #   max_val = max(visited[y])
  #   max_len = max_len if max_len > max_val else max_val
  # print(max_len)
  print(np.max(visited))

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

N=int(input())
counts=[]
A=[]
S=[]
T=[]
U=[]
for _ in range(N):
    s=input()
    S.append(s)
    if s not in T:
        T.append(s)
t=sorted(T)
for i in t:
    U.append(S.count(i))
V=[j for j,v in enumerate(U) if v==max(U)]

for k in V:
    print(t[k])

### FIXED CODE ###

N=int(input())
S=[input() for _ in range(N)]

S_d={}
A=[]

for i in range(N):
    if S[i] not in S_d.keys():
        S_d[S[i]]=1
    else:
        S_d[S[i]]+=1

max_co=max(S_d.values())

for j in S_d.keys():
    if S_d[j]==max_co:
        A.append(j)

B=sorted(A)

for k in B:
    print(k)
### BUGGY CODE ###

import math
A, B, N = map(int, input().split())
ans = []
for x in range(0, 10**3):
    cal = math.floor((A*x)/B) - (int(A) * math.floor(x/B))
    ans.append(cal)
for x in range(N-10**7, N+1):
    cal = math.floor((A*x)/B) - (int(A) * math.floor(x/B))
    ans.append(cal)
print(max(ans))

### FIXED CODE ###

a, b, n = map(int, input().split())
n = min(n, b-1)
 
print(int((a * n) / b) - a * int(n / b))
### BUGGY CODE ###

from sys import stdin
import sys
from itertools import groupby
sys.setrecursionlimit(10**6) 
n,q = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n-1)]
lin = [list(map(int,stdin.readline().rstrip().split())) for _ in range(q)]

kazu = [[]for _ in range(n)]
point = [0]*n

for i in range(len(li)):
    kazu[li[i][0]-1].append(li[i][1]-1)
    kazu[li[i][1]-1].append(li[i][0]-1)
for i in range(q):
    point[lin[i][0]-1] += lin[i][1]

def dfs(li,li2,now,before):
    for i in (li[now]):
        if i == before:
            continue
        li2[i] += li2[now]
        dfs(kazu,point,i,now)
dfs(kazu,point,0,-1)
print(*point)

### FIXED CODE ###

from sys import stdin
import sys
from itertools import groupby
sys.setrecursionlimit(10**6) 
n,q = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n-1)]
lin = [list(map(int,stdin.readline().rstrip().split())) for _ in range(q)]

kazu = [[]for _ in range(n)]
point = [0]*n

for i in range(len(li)):
    kazu[li[i][0]-1].append(li[i][1]-1)
    kazu[li[i][1]-1].append(li[i][0]-1)
for i in range(q):
    point[lin[i][0]-1] += lin[i][1]

def dfs(li,li2,now,before):
    for i in (li[now]):
        if i == before:
            continue
        li2[i] += li2[now]
        dfs(kazu,point,i,now)
dfs(kazu,point,0,-1)
print(*point)
### BUGGY CODE ###

def cake(s1,s2,s3):
    ans1 = sorted(i+j for i in s1 for j in s2)
    ans2 = sorted(i+j for i in ans1 for j in s3)
    return ans2    
    
a,b,c,d = map(int, input().split())

s1=list(map(int, input().split()))
s2=list(map(int, input().split()))
s3=list(map(int, input().split()))

z = sorted(cake(s1,s2,s3),reverse=True)
for i in range(0,d):
    print(z[i])

### FIXED CODE ###

import sys
input = sys.stdin.readline
 
x, y, z, k = map(int, input().split())
a = sorted(int(i) for i in input().split())
b = sorted(int(i) for i in input().split())
c = sorted(int(i) for i in input().split())
 
#a.sort(reverse=True)
#b.sort(reverse=True)
#c.sort(reverse=True)
 
ab = sorted(i+j for i in a for j in b)[:-k-1:-1]
abc = sorted(i+j for i in ab for j in c)[:-k-1:-1]
 
print(*abc[:k], sep="\n")
### BUGGY CODE ###

import sys
from math import factorial
from collections import Counter
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7

n, k = MAP()
a = LIST()
tugi = [0]+a
town  =1
temp = [""]*n
temp[0] = town

for i in range(n):
    town = tugi[town]
    if town in temp:
        i = temp.index(town)
        notcycle = temp[:i]
        cycle = temp[i:]
        break
    temp[i+1] = town

for i in range(n):
    if cycle[i] == "":
        cycle = cycle[:i]
        break

if len(notcycle) >k:
    print(notcycle[k])
else:
    k -= len(notcycle)
    print(cycle[k%len(cycle)])

### FIXED CODE ###

import sys
from math import factorial
from collections import Counter
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7

n, k = MAP()
a = LIST()
tugi = [0]+a
town  =1
route = [0]*n
route[0] = town
used = [False]*n
used[0] = True
for i in range(n):
    town = tugi[town]
    if used[town-1]:
        i = route.index(town)
        notcycle = route[:i]
        cycle = route[i:]
        break
    used[town-1] = True
    route[i+1] = town

for i in range(n):
    if cycle[i] == 0:
        cycle = cycle[:i]
        break

if len(notcycle) >k:
    print(notcycle[k])
else:
    k -= len(notcycle)
    print(cycle[k%len(cycle)])
### BUGGY CODE ###

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

inf = 10**9
dp = [inf] * (N+5)

dp[0] = 0
for i in range(N):
    dp[i] = min(dp[i - k] + abs(A[i] - A[i - k]) for k in range(min(i, K) + 1))

print(dp[N-1])


### FIXED CODE ###

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

dp=[100000 for i in range(N)]
dp[0]=0

for i,h_now in enumerate(h):
    if i==0:
        continue
    x=max(0,i-K)
    dp[i]=min([dp_i+abs(h_now-h_i) for dp_i,h_i in zip(dp[x:i],h[x:i])])

print(dp[N-1])
### BUGGY CODE ###

n=int(input())
A=list(int(i) for i in input().split())
dp=[[[0,0] for i in range(n)] for j in range(n)]
for i in range(n-1,-1,-1):
    for j in range(i,n):
        if i<=j:
            if i==j:
                dp[i][j][0]=A[i]
                dp[i][j][1]=-A[i]
            else:
                dp[i][j][0]=max(A[i]+dp[i+1][j][1],A[j]+dp[i][j-1][1])
                dp[i][j][1]=min(-A[i]+dp[i+1][j][0],-A[j]+dp[i][j-1][0])
print(dp[0][-1][0])


### FIXED CODE ###

#dp=[[ for i in range(3000)] for j in range(3000)]
n=int(input())
A=list(int(i) for i in input().split())
dp=[[0 for i in range(n)] for j in range(n)]
for i in range(n-1,-1,-1):
    for j in range(i,n):
        if i==j:
            dp[i][j]=A[i]
        else:
            dp[i][j]=max(A[i]-dp[i+1][j],A[j]-dp[i][j-1])
print(dp[0][-1])
### BUGGY CODE ###

N = int(input())
An = [int(n) for n in input().split()]
M = sorted(set(An))
mini=M[0]
for i,x in enumerate(M):
    M = [mini] + [x for x in M[1:] if x % mini != 0]
            
while len(M) > 1:
    M = list(map(lambda x:x-mini,M))
    M[0] = mini
    M.sort()
    if 1 in M:
        mini=1
        break
#    while M[0]<1:
#        M.pop(0)
    mini = min(mini,M[0])
print(mini)    


### FIXED CODE ###

N = int(input())
An = [int(n) for n in input().split()]
M = sorted(set(An))
mini=M[0]
            
while len(M) > 1:
    M = [mini] + [x%mini for x in M[1:] if x % mini != 0]
    M.sort()
    if 1 in M:
        mini=1
        break
    mini = min(mini,M[0])
print(M[0])
### BUGGY CODE ###

import math

X = int(input())

ans = None

while ans is None:
  for i in range(math.ceil(abs(X)**0.5)+1, 0, -1):
    for j in range(math.ceil(abs(X)**0.5)+1, 0, -1):
      if i ** 5 - j ** 5 == X:
        ans = (i, j)
      elif (i*-1) ** 5 - j ** 5 == X:
        ans = (-i, j)
      elif i ** 5 - (j*-1) ** 5 == X:
        ans = (i, -j)
      elif (i*-1) ** 5 - (j*-1) ** 5 == X:
        ans = (-i, -j)
print(ans[0],ans[1])

### FIXED CODE ###

X = int(input())
 
ans = None
 
for i in range(120):
  for j in range(120):
    if i ** 5 - j ** 5 == X:
      ans = (i, j)
    elif (i*-1) ** 5 - j ** 5 == X:
      ans = (-i, j)
    elif i ** 5 - (j*-1) ** 5 == X:
      ans = (i, -j)
print(ans[0],ans[1])
### BUGGY CODE ###

def main():
    n = int(input())
    a = list(map(int, input().split()))
    if 0 in a:
        print(0)
        return
    ans = 1
    for cal in a:
        ans *= cal
    if ans > 1e18:
        ans = -1
    print(ans)


main()


### FIXED CODE ###

def main():
    n = int(input())
    a = list(map(int, input().split()))
    if 0 in a:
        print(0)
        return
    ans = 1
    for cal in a:
        ans *= cal
        if ans > 1e18:
            print(-1)
            return
    print(ans)

main()
### BUGGY CODE ###

n=int(input())
a=1
for i in range(1,n+1):
    a*=i
print(a%(10**9+7))

### FIXED CODE ###

a=1
for i in range(1,int(input())+1):
    a=(i*a)%(10**9+7)
print(a)
### BUGGY CODE ###

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


B = sorted(list(set(A)), reverse=True)

for i in range(len(B)):
    b = B[i]
    if A.count(b) >= 4:
        print(b**2)
        exit()
    elif A.count(b) >=2:
        C = B[i+1:]
        for c in C:
            if  A.count(c) >= 2:
                print(b*c)
                exit()

print(0)


### FIXED CODE ###

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

x = 0
y = 0
S = set()

for a in A:
    if a in S:
        if a < x:
            continue
        elif a > y:
            x = y
            y = a
        else:
            x = a
        S.remove(a)
    else:
        S.add(a)

print(x*y)
### BUGGY CODE ###

import math

place_count = int(input())
position_list = input().split()

now_position = 0
cost = 0
cost_dict = {}

for skip_position in position_list:
	if skip_position in cost_dict:
		print(cost_dict[skip_position])
	skip_position = int(skip_position)
	for next_position in position_list:
		next_position = int(next_position)
		if skip_position == next_position:
			continue
		cost += abs(next_position - now_position)
		now_position = next_position
	cost += abs(now_position)
	print(cost)
	cost_dict[skip_position] = cost
	now_position = 0
	cost = 0


### FIXED CODE ###

place_count = int(input())
position_list = [0] + list(map(int, input().split()))
position_list.append(0)

all_sum = 0

for i in range(0, place_count+1):
	all_sum += abs(position_list[i+1] - position_list[i])

for x in range(1, place_count+1):
	print(all_sum - abs(position_list[x-1] - position_list[x]) - abs(position_list[x+1] - position_list[x]) + abs(position_list[x+1] - position_list[x-1]))