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

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

for i in range(N):
  pos=0
  cost=0
  for j in range(N):
    if j==i:
      pass
    else:
      #print(j,A[j])
      cost += abs(A[j]-pos)
      pos= A[j]
  if i==N-1:
    cost += abs(A[-2])
  else:
    cost += abs(A[-1])  
  print(cost)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
B=[abs(A[0])]

for i in range(1,N):
  B.append(B[-1] + abs(A[i]-A[i-1]))
  
total=B[-1]+abs(A[-1])

for j in range(N):
  ans=total
  if 0<j<N-1:
    ans -= abs(A[j]-A[j-1])
    ans -= abs(A[j+1]-A[j])
    ans += abs(A[j+1]-A[j-1])
  elif j==0:
    ans -= abs(A[0])
    ans -= abs(A[1]-A[0])
    ans += abs(A[1])
  else:
    ans -= abs(A[-1]-A[-2])
    ans -= abs(A[-1])
    ans += abs(A[-2])
  print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-

from collections import deque
import copy

class Puzzle(list):
    def __init__(self, size):
        list.__init__(self)
        self.size = size
        #self[:] = [None] * size
        self.space = None
        self.path = ""

if __name__ == '__main__':
    
    N = 3
    N2 = 9
    dx = [-1, 0, 1, 0]
    dy = [0, -1, 0, 1]
    d = ["u", "l", "d", "r"]

    p = Puzzle(N2)
    for i in range(N):
        p += [int(x) for x in input().split()]
    for i in range(N2):
        if p[i] == 0:
            p[i] = N2
            p.space = i
    def isTarget(p):
        for i in range(N2):
            if p[i] != i+1:
                return False
        return True

    def bfs(s):
        cnt = 0
        Q = deque()
        V = []
        Q.append(s)
        V.append(s)
        while Q:
            cnt += 1
            u = Q.popleft()
            if isTarget(u):
                return u.path
            sx = u.space // N
            sy = u.space % N
            for r in range(4):
                tx = sx + dx[r]
                ty = sy + dy[r]
                if tx < 0 or ty < 0 or tx >= N or ty >= N:
                    continue
                v = copy.copy(u)
                v[u.space], v[tx * N + ty] = v[tx * N + ty], v[u.space]
                v.space = tx * N + ty
                if not v in V:
                    V.append(v)
                    v.path += d[r]
                    Q.append(v)

        return "unsolvable"

    ans = bfs(p)
    print(len(ans))





### FIXED CODE ###

# -*- coding: utf-8 -*-

from collections import deque
import copy

class Puzzle(list):
    def __init__(self):
        list.__init__(self)
        self.space = None
        self.path = ""
    
    def __hash__(self):
        return hash(str(self[:]))

if __name__ == '__main__':
    
    N = 3
    N2 = 9
    dx = [-1, 0, 1, 0]
    dy = [0, -1, 0, 1]
    d = ["u", "l", "d", "r"]

    p = Puzzle()
    for i in range(N):
        p += [int(x) for x in input().split()]
    for i in range(N2):
        if p[i] == 0:
            p[i] = N2
            p.space = i
    target = [1, 2, 3, 4, 5, 6, 7, 8, 9]
    def isTarget(p):
        return p[:] == target[:]

    def bfs(s):
        Q = deque()
        V = set()
        Q.append(s)
        V.add(s)
        while Q:
            u = Q.popleft()
            if isTarget(u):
                return u.path
            sx = u.space // N
            sy = u.space % N
            for r in range(4):
                tx = sx + dx[r]
                ty = sy + dy[r]
                if not (0<= tx < N and 0 <= ty < N):
                    continue
                v = Puzzle()
                v[:] = u[:]
                v.path = u.path
                change = tx * N + ty
                v[u.space], v[change] = v[change], v[u.space]
                v.space = change
                if not v in V:
                    V.add(v)
                    v.path += d[r]
                    Q.append(v)

        return "unsolvable"

    ans = bfs(p)
    print(len(ans))
### BUGGY CODE ###

import sys
import math
from  collections import defaultdict

# sys.stdin = open('input.txt', 'r')
# sys.stdout = open('output.txt', 'w')

sys.setrecursionlimit(1000000)

def solve(test):
	s = input()
	t = input()
	memo = {}
	ans = lcs(s, t, 0, 0, memo)
	print(ans)

def lcs(s, t, i, j, memo):
	if (i, j) in memo:
		return memo[(i, j)]
	elif i == len(s) or j == len(t):
		return ''
	else:
		ans = ''
		if s[i] == t[j]:
			ans = s[i] + lcs(s, t, i + 1, j + 1, memo)
		else:
			s1 = lcs(s, t, i + 1, j, memo)
			s2 = lcs(s, t, i, j + 1, memo)
			if len(s1) >= len(s2):
				ans = s1
			else:
				ans = s2
		memo[(i, j)] = ans
		return ans


if __name__ == "__main__":
	test_cases = 1
	for t in range(1, test_cases + 1):
		solve(t)


### FIXED CODE ###

import sys
import math
from  collections import defaultdict

# sys.stdin = open('input.txt', 'r')
# sys.stdout = open('output.txt', 'w')


def solve(test):
	s = [''] + list(input())
	t = [''] + list(input())
	rec = [[0 for j in range(len(t))] for i in range(len(s))]
	for i in range(1, len(s)):
		for j in range(1, len(t)):
			if s[i] == t[j]:
				rec[i][j] = 1 + rec[i - 1][j - 1]
			else:
				rec[i][j] = max(rec[i - 1][j], rec[i][j - 1])

	ans = []
	i, j = len(s) - 1, len(t) - 1
	while i >= 0 and j >= 0:
		if s[i] == t[j]:
			ans.append(s[i])
			i -= 1
			j -= 1
		elif rec[i - 1][j] > rec[i][j - 1]:
			i -= 1
		else:
			j -= 1

	print(''.join(ans[::-1]))


if __name__ == "__main__":
	test_cases = 1
	for t in range(1, test_cases + 1):
		solve(t)
### BUGGY CODE ###

N, M, Q = map(int, input().split())
Ls = [0] * N
Rs = [0] * N
for i in range(M):
  L, R = map(int, input().split())
  Ls[L-1] |= 1 << i
  Rs[R-1] |= 1 << i

for i in range(N-1):
  j = N - 1 - i
  Rs[i+1] |= Rs[i]
  Ls[j-1] |= Ls[j]

for i in range(Q):
  p, q = map(int, input().split())
  print(bin(Ls[p-1] & Rs[q-1]).count('1'))

### FIXED CODE ###

N, M, Q = map(int, input().split())
MAP = [[0] * N for i in range(N)]
for i in range(M):
  L, R = map(int, input().split())
  MAP[L-1][R-1] += 1

for r in range(N):
  for l in range(N-1, 0, -1):
    MAP[l-1][r] += MAP[l][r]

for r in range(N-1):
  for l in range(N):
    MAP[l][r+1] += MAP[l][r]

for i in range(Q):
  p, q = map(int, input().split())
  print(MAP[p-1][q-1])
### BUGGY CODE ###

MAX = 10**9 + 7

def mod_inv(i, MOD):
    return pow(i, MOD-2, MOD)

def combination(_N, _K):
    if _K > (_N/2):
        _K = _N - _K
    up = 1
    low = 1
    for i in range (_K):
        up *= (_N - i) % MAX
        low *= (i + 1) % MAX
    ret = up * mod_inv(low, MAX)
    if ret >= MAX:
        ret %= MAX
    return ret

def solve():
    N, M, K = [int(_) for _ in raw_input().split()]
    disSum = M*N* (M*(N+1)*(N-1) + N*(M+1)*(M-1)) * mod_inv(6, MAX)
    if disSum >= MAX:
        disSum %= MAX
    ret = disSum * combination(M*N-2, K-2)
    if ret >= MAX:
        ret %= MAX
    print ret

if __name__ == '__main__':
    solve()


### FIXED CODE ###

MAX = 10**9 + 7

def mod_inv(i, mod):
    return pow(i, mod-2, mod)

def combination(_N, _K):
    if _K > (_N/2):
        _K = _N - _K
    up = 1
    low = 1
    for i in range (_K):
        up = up * (_N - i) % MAX
        low = low * (i + 1) % MAX
    ret = up * mod_inv(low, MAX) % MAX
    return ret

def solve():
    N, M, K = [int(_) for _ in raw_input().split()]
    disSum = (M*N* ((M*(N+1)*(N-1))%MAX + (N*(M+1)*(M-1)) % MAX)) % MAX
    disSum *= mod_inv(6, MAX) % MAX
    ret = disSum * combination(M*N-2, K-2) % MAX
    print ret

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

n=int(input())
a=list(map(int,input().split()))
ans=1
for i in range(len(a)):
    ans*=a[i]
if ans>10**18:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
a1=sorted(a,reverse=True)
a2=sorted(a)
ans=1
if len(a)<90:
    for i in range(len(a)):
        ans*=a[i]

else:
    if a2[0]==0:
        ans=0
    elif a1[90]>1:
        ans=-1
    else:
        del a1[90:]
        for i in range(len(a1)):
           ans*=a1[i]
if ans>10**18:
    print(-1)
else:
    print(ans)
### BUGGY CODE ###

X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

ans = []
for i in range(X):
    for j in range(Y):
        for k in range(Z):
            if (i+1)*(j+1)*(k+1) <= K: ans.append(A[i]+B[j]+C[k])
ans.sort(reverse=True)
for i in range(K): print(ans[i])

### FIXED CODE ###

X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

ans = []
for i in range(X):
    for j in range(Y):
        for k in range(Z):
            if (i+1)*(j+1)*(k+1) <= K: ans.append(A[i]+B[j]+C[k])
            else: break
ans.sort(reverse=True)
for i in range(K): print(ans[i])
### BUGGY CODE ###

import sys
sys.setrecursionlimit(1000000)

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

edge = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    edge[a].append(b)
    edge[b].append(a)

counter = [0] * (N + 1)
for _ in range(Q):
    p, x = map(int, input().split())
    counter[p] += x

# print(edge)
# print(counter)

visited = [False] * (N + 1)
ans = [0] * (N + 1)

def dfs(fro, p):
    visited[fro] = True
    now = counter[fro] + p
    for to in edge[fro]:
        if not visited[to]:
            dfs(to, now)
    ans[fro] = now
    return

dfs(1, 0)

print(*ans[1:])


### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

def input():
    return sys.stdin.readline()

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

edge = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    edge[a].append(b)
    edge[b].append(a)

counter = [0] * (N + 1)
for _ in range(Q):
    p, x = map(int, input().split())
    counter[p] += x

# print(edge)
# print(counter)

visited = [False] * (N + 1)
visited[1] = True
ans = [0] * (N + 1)

def dfs(fro, p):
    visited[fro] = True
    now = counter[fro] + p
    for to in edge[fro]:
        if not visited[to]:
            dfs(to, now)
    ans[fro] = now
    return

dfs(1, 0)

print(*ans[1:])
### BUGGY CODE ###

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

count = 0
for i in range(n):
    li = p[:i+1]
    if min(li) == p[i]:
        count += 1
        
print(count)

### FIXED CODE ###

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

m = p[0]
count = 1
for i in range(1,n):
    if m >= p[i]:
        m = p[i]
        count += 1
        
print(count)
### BUGGY CODE ###

n = int(input())
ans = 1
for i in range(1,n+1):
    ans *= i
print(ans%1000000007)

### FIXED CODE ###

import math 
n = int(input())
print(math.factorial(n)%1000000007)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
ri = lambda: int(input())
#rl = lambda: [int(x) if x.isdecimal() else x for x in input().split()]
#rl = lambda: list(input().split()))
rl = lambda: map(int,input().split())
rr = lambda N: [list(l) for l in zip(*[rl() for _ in range(N)])]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18
MOD = 10**9+7

H,W=rl()
S=[]
for i in range(H):
    S.append(input())
M = [[0 for w in range(W)] for h in range(H)]
wM = [[0 for w in range(W)] for h in range(H)]

for h in range(H):
    cnt = 0
    for w in range(W):
        if S[h][w] == '#':
            M[h][w] = 1
            for c in range(1,cnt+1):
                wM[h][w-c] = cnt
            cnt = 0
        else:
            cnt += 1
    for c in range(1,cnt+1):
        wM[h][W-c] = cnt

for w in range(W):
    cnt = 0
    for h in range(H):
        if M[h][w] == 1:
            for c in range(1,cnt+1):
                wM[h-c][w] += cnt -1
            cnt = 0
        else:
            cnt += 1
    for c in range(1,cnt+1):
        wM[h-c][w] += cnt -1

ans = 0
for ret in wM:
    ans = max(ans,max(ret))

print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
ri = lambda: int(input())
#rl = lambda: [int(x) if x.isdecimal() else x for x in input().split()]
#rl = lambda: list(input().split()))
rl = lambda: map(int,input().split())
rr = lambda N: [list(l) for l in zip(*[rl() for _ in range(N)])]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18
MOD = 10**9+7


H,W=rl()
S=[]
for i in range(H):
    S.append(input())
#M = [[0 for w in range(W)] for h in range(H)]
wM = [[0 for w in range(W)] for h in range(H)]
hM = [[0 for w in range(W)] for h in range(H)]

for h in range(H):
    cnt = 0
    for w in range(W):
        if S[h][w] == '#':
            #M[h][w] = 1
            wM[h][w-1] = cnt
            cnt = 0
        else:
            wM[h][w] = -1
            cnt += 1
    if cnt != 0:
        wM[h][W-1] = cnt

for h in range(H):
    cnt = 0
    for w in range(W-1,-1,-1):
        if wM[h][w] > 0:
            cnt = wM[h][w]
        elif wM[h][w] == -1:
            wM[h][w] = cnt

for w in range(W):
    cnt = 0
    for h in range(H):
        if S[h][w] == "#":
        #if M[h][w] == 1:
            hM[h-1][w] = cnt 
            cnt = 0
        else:
            hM[h][w] = -1
            cnt += 1
    if cnt != 0:
        hM[H-1][w] = cnt

for w in range(W):
    cnt = 0
    for h in range(H-1,-1,-1):
        if hM[h][w] > 0:
            cnt = hM[h][w]
        elif hM[h][w] == -1:
            hM[h][w] = cnt

ans = 0
for h in range(H):
    for w in range(W):
        ret1 = wM[h][w]
        ret2 = hM[h][w]
        ret = ret1 + ret2
        if ret1 != 0 and ret2 != 0:
            ret -= 1
        ans = max(ans,ret)
print(ans)
### BUGGY CODE ###

import sys
n,m = map(int, sys.stdin.readline().rstrip("\n").split())
cage = {}
for i in range (2,n+1):
    cage[i] = None
ab = [map(int, line.rstrip("\n").split()) for line in sys.stdin]
a,b = [list(i) for i in zip(*ab)]
room = [1]
nroom = []
while None in cage.values():
    for i in range(len(room)):
        j = 0
        while j < (len(a)):
            if a[j] == room[i]:
                if cage[b[j]] == None:
                    cage[b[j]] = a[j]
                nroom.append(b[j])
                a.pop(j)
                b.pop(j)
            elif b[j] == room[i]:
                if cage[a[j]] == None:
                    cage[a[j]] = b[j]
                nroom.append(a[j])
                a.pop(j)
                b.pop(j)
            else:
                j += 1
    if (len(a) == 0 and None in cage.values()) or room == nroom:
        print('No')
        break
    room = nroom[:]
    nroom.clear()
else:
    print('Yes')
    for i in range (2,n+1):
        print(cage[i])

### 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 ###

from operator import itemgetter
n,k = map(int,input().split())
li=[]
s=[]
t=[]
g=0
ans=[]
for _ in range(n):
    a,b=map(int,input().split())
    li.append([a,b])
li=sorted(li,key=itemgetter(1),reverse=True)
for i in range(k):
    g+=li[i][1]
    if li[i][0] not in s:
        s.append(li[i][0])
    else:
        t.append(li[i][1])
p=len(s)
g+=p**2
ans.append(g)
for i in range(k,n):
    if len(t)==0:
        break
    if li[i][0] not in s:
        g=g-t[-1]+li[i][1]+2*p+1
        p+=1
        ans.append(g)
        s.append(li[i][0])
print(max(ans))

### FIXED CODE ###

from operator import itemgetter
n,k = map(int,input().split())
li=[]
s=[]
t=[]
g=0
ans=[]
retu=[0]*n
p=0
q=0
for _ in range(n):
    a,b=map(int,input().split())
    li.append([a,b])
li=sorted(li,key=itemgetter(1),reverse=True)
for i in range(k):
    g+=li[i][1]
    if retu[li[i][0]-1]==0:
        retu[li[i][0]-1]+=1
        p+=1
    else:
        t.append(li[i][1])
        q+=1
g+=p**2
ans.append(g)
for i in range(k,n):
    if q==0:
        break
    if retu[li[i][0]-1]==0:
        g=g-t[q-1]+li[i][1]+2*p+1
        p+=1
        q-=1
        ans.append(g)
        retu[li[i][0]-1]+=1
print(max(ans))
### BUGGY CODE ###

N,Ma,Mb=list(map(int, input().strip().split()))
abc=[list(map(int, input().strip().split())) for i in range(N)]
maxW=N*10
dp=[[[float("inf")]*(maxW+1) for _ in range(maxW+1)]for __ in range(N+1)]
dp[0][0][0]=0
for i in range(N):
    a,b,c=abc[i]
    for ai  in range(maxW):
        for bi in range(maxW):
            if dp[i][ai][bi]==float("inf"):continue
            dp[i+1][ai][bi] = min(dp[i+1][ai][bi],dp[i][ai][bi])
            dp[i+1][ai+a][bi+b] = min(dp[i][ai][bi]+c,dp[i+1][ai+a][bi+b])
cost=float("inf")
Mad=Ma
Mbd=Mb
while Ma<=maxW and Mb <=maxW:
    cost=min(dp[-1][Ma][Mb],cost)
    Ma+=Mad
    Mb+=Mbd
print(-1 if cost==float("inf") else cost)

### FIXED CODE ###

N,Ma,Mb=list(map(int, input().strip().split()))
abc=[list(map(int, input().strip().split())) for i in range(N)]
maxW=N*10
dp=[{} for __ in range(N+1)]
dp[0][(0,0)]=0
for i in range(N):
    a,b,c=abc[i]
    for k,v in dp[i].items():
        dp[i+1][k]=min(dp[i][k], dp[i+1][k]if k in dp[i+1] else float("inf"))
        dp[i+1][k[0]+a,k[1]+b]=min(dp[i][k]+c, dp[i+1][k[0]+a,k[1]+b] if (k[0]+a,k[1]+b)in dp[i+1] else float("inf"))

cost=float("inf")
Mad=Ma
Mbd=Mb
while Ma<=maxW and Mb <=maxW:
    if (Ma,Mb) in dp[-1]:
        cost=min(dp[-1][Ma,Mb],cost)
    Ma+=Mad
    Mb+=Mbd
print(-1 if cost==float("inf") else cost)
### BUGGY CODE ###

def culc(s,c,l,b,x,y):
    if s == l-1:
        return s
    if x+y >b[c]:
        s = c
        c = int((c+l)/2)
        return culc(s,c,l,b,x,y)
    else:
        l = c
        c = int((c+s)/2)
        return culc(s,c,l,b,x,y)
N = int(input())
b = list(int(i) for i in input().split())
b.sort()
sum_N = 0
for i,x in enumerate(b):
    for y in range(i+1,N,1):
        c = int((i+N)/2)
        lim_num =culc(i+1,c,N,b,x,b[y])
        sum_N += lim_num-y
print(sum_N)

### FIXED CODE ###

import bisect    
    
N = int(input())
b = list(int(i) for i in input().split())
b.sort()
sum_N = 0
for i,x in enumerate(b):
    s = i+1
    for y in range(i+1,N,1):
        index = bisect.bisect_left(b,x+b[y])
        sum_N += max(0,index - y -1)
print(sum_N)
### BUGGY CODE ###


def gcd(a, b):
	while b > 0:
		a, b = b, a % b
	return a


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

if N == 2:
  print(max(A))
else:
  m = -1
  for i in range(N):
    G = 0
    for j in range(0, i):
      G = gcd(G, A[j])
    for j in range(i+1, N):
      G = gcd(G, A[j])

    m = max(m, G)
  print(m)

### FIXED CODE ###


def gcd(a, b):
	while b > 0:
		a, b = b, a % b
	return a


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

if N == 2:
  print(max(A))
else:

  L = [0 for j in range(N+1)]
  R = [0 for j in range(N+1)]
  
  for j in range(N):
    L[j+1] = gcd(L[j], A[j])
  for j in reversed(range(N)):
    R[j] = gcd(R[j+1], A[j])

    m = -1
  for j in range(N):
    m = max(m, gcd(L[j], R[j+1]))
  print(m)
### BUGGY CODE ###

import collections
import itertools

N = int(input())
s_list = []
for i in range(N):
    s_list.append(input())

#s_list.sort()
l = []
for s in s_list:
    l2 = []
    for i in range(len(s)):
        l2.append(s[i])
    l.append(l2)
    
for i in l:
    i.sort()

l3 = []
for i in l:
    s = ""
    for j in i:
        s += j
    l3.append(s)
    
C = collections.Counter(l3)
ans = 0
for i in C:
    ans += len(list(itertools.combinations(range(C[i]), 2)))
print(ans)

### FIXED CODE ###

import collections
import itertools
ans = 0

N = int(input())
s_list = []
for i in range(N):
    s_list.append(input())

d = {}
for s in s_list:
    l2 = []
    for i in range(len(s)):
        l2.append(s[i])
    l2.sort()
    a = ""
    for i in l2:
        a += i
    if a in d:
        ans+=d[a]
        d[a]+=1
    else:
        d[a] = 1

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

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

tar = 1
for i in A:
    tar *= i

if tar > 10 ** 18:
    print(-1)
else:
    print(tar)


### FIXED CODE ###


import sys
N = int(input())
A = list(map(int, input().split()))
A.sort()
tar = 1
for i in A:
    tar *= i
    if tar > 10 ** 18:
        print('-1')
        sys.exit()

print(tar)
### BUGGY CODE ###

def mergecount(A):
    cnt = 0
    n = len(A)
    if n>1:
        A1 = A[:n>>1]
        A2 = A[n>>1:]
        cnt += mergecount(A1)
        cnt += mergecount(A2)
        i1 = 0
        i2 = 0
        for i in range(n):
            if i2 == len(A2):
                A[i] = A1[i1]
                i1 += 1
            elif i1 == len(A1):
                A[i] = A2[i2]
                i2 += 1
            elif A1[i1] <= A2[i2]:
                A[i] = A1[i1]
                i1 += 1
            else:
                A[i] = A2[i2]
                i2 += 1
                cnt += n//2 - i1
    return cnt


n = int(input())
l = [int(_) for _ in input().split()]
p = (n*n+n)/2
q = 0
if p%2 == 0:
    q = p//2
else:
    q = p//2 + 1
l_set = list(set(l))
l_sorted = sorted(l_set)
ans = 0

low = 0
high = len(l_sorted) - 1


while low <= high:
    mid = (low + high) // 2
    m = l_sorted[mid]
    l_t = [0 for _ in range(n)]
    for j in range(n):
        if l[j] < m:
            l_t[j] = -1
        else:
            l_t[j] = 1
    s = [0 for _ in range(n+1)]
    for k in range(n):
        s[k+1] = s[k] + l_t[k]

    x = mergecount(s)
    if p-x >= q:
        low = mid+1
        ans = max(m,ans)
    else:
        high = mid-1
print(ans)

### FIXED CODE ###

def mergecount(A):
    cnt = 0
    n = len(A)
    if n>1:
        A1 = A[:n>>1]
        A2 = A[n>>1:]
        cnt += mergecount(A1)
        cnt += mergecount(A2)
        i1 = 0
        i2 = 0
        for i in range(n):
            if i2 == len(A2):
                A[i] = A1[i1]
                i1 += 1
            elif i1 == len(A1):
                A[i] = A2[i2]
                i2 += 1
            elif A1[i1] <= A2[i2]:
                A[i] = A1[i1]
                i1 += 1
            else:
                A[i] = A2[i2]
                i2 += 1
                cnt += n//2 - i1
    return cnt
 
 
n = int(input())
l = [int(_) for _ in input().split()]
p = (n*n+n)/2
q = 0
if p%2 == 0:
    q = p//2
else:
    q = p//2 + 1
l_set = list(set(l))
l_sorted = sorted(l_set)
ans = 0
l_t = [0 for _ in range(n)]
s = [0 for _ in range(n+1)]
 
low = 0
high = len(l_sorted) - 1
 
 
while low <= high:
    mid = (low + high) // 2
    m = l_sorted[mid]
    for j in range(n):
        if l[j] < m:
            l_t[j] = -1
        else:
            l_t[j] = 1
    for k in range(n):
        s[k+1] = s[k] + l_t[k]
 
    x = mergecount(s)
    if p-x >= q:
        low = mid+1
        ans = max(m,ans)
    else:
        high = mid-1
print(ans)
### BUGGY CODE ###

from collections import Counter

n = int(input())

a_list = list(map(int, input().split()))

ans_dict = {}
value_dict = {1: 0}
for i in range(n):
    num = a_list[i]
    if num in ans_dict.keys():
        print(ans_dict[num])
    else:
        c = Counter(a_list[:i] + a_list[i+1:])

        tmp_ans = 0
        for value in c.values():
            if value in value_dict.keys():
                tmp_ans += value_dict[value]
            else:
                tmp = int((value * (value - 1))/2)
                tmp_ans += tmp
                value_dict[value] = tmp
        ans_dict[num] = tmp_ans
        print(tmp_ans)



### FIXED CODE ###

from collections import Counter

n = int(input())

a_list = list(map(int, input().split()))

c = Counter(a_list)

all_count = 0
for value in c.values():
    if value == 1:
        continue
    else:
        tmp = int((value * (value - 1))/2)
        all_count += tmp

for i in a_list:
    print(all_count - c[i] + 1)
### BUGGY CODE ###

N=int(input())
L=list(map(int,input().split()))
while len(L)>1:
	m=L.index(max(L))
	L[m]=max(L)-min(L)
	if L[m]<=0:
		L.pop(m)
print(L[0])

### FIXED CODE ###

from functools import reduce
from fractions import gcd
input()
print(reduce(gcd,map(int,input().split())))