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

import collections
n = int(input())
l = []
ans = []

for i in range(n):
    l.append(input())

c = collections.Counter(l)

ans = [i[0] for i in c.items() if i[1] == max(c.values())]

ans.sort()

print('\n'.join(map(str, ans)))

### FIXED CODE ###

n = int(input())

d = {}

for i in range(n):
    a = input()
    if a in d:
        d[a] += 1
    else:
        d[a] = 1

m = max(d.values())
d = sorted(d.items())

for j in d:
    if j[1] == m:
        print(j[0])
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
input = sys.stdin.readline

# bisect_left(lists, 3)
# bisect_right(lists, 3)

def main():
	X, Y, Z, K = map(int, input().split(" "))
	As = []
	Bs = []
	Cs = []
	As = input().split()
	As = [int(s) for s in As]
	Bs = input().split()
	Bs = [int(s) for s in Bs]
	Cs = input().split()
	Cs = [int(s) for s in Cs]

	As.sort(reverse=True)
	Bs.sort(reverse=True)
	Cs.sort(reverse=True)

	As = As[:K]
	Bs = Bs[:K]
	Cs = Cs[:K]

	ans = []
	for i, val in enumerate(As):
		for j, vol in enumerate(Bs):
			for k, ogi in enumerate(Cs):
				ans.append(val+vol+ogi)

	ans.sort(reverse=True)
	for i in range(K):
		print(ans[i])
	
if __name__ == "__main__":
	main()
	

### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
input = sys.stdin.readline

# bisect_left(lists, 3)
# bisect_right(lists, 3)

def main():
	X, Y, Z, K = map(int, input().split(" "))
	As = []
	Bs = []
	Cs = []
	As = input().split()
	As = [int(s) for s in As]
	Bs = input().split()
	Bs = [int(s) for s in Bs]
	Cs = input().split()
	Cs = [int(s) for s in Cs]

	As.sort(reverse=True)
	Bs.sort(reverse=True)
	Cs.sort(reverse=True)

	ans1 = []
	for i, val in enumerate(As):
		for j, vol in enumerate(Bs):
			ans1.append(val+vol)

	ans1.sort(reverse=True)
	ans1 = ans1[:3000]

	ans2 = []
	for i, val in enumerate(ans1):
		for j, vol in enumerate(Cs):
			ans2.append(val+vol)

	ans2.sort(reverse=True)
	for i in range(K):
		print(ans2[i])
	
if __name__ == "__main__":
	main()
### BUGGY CODE ###

n = int(input())
s = []
for _ in range(n):
    s.append(input())


i = n#
j = 0#何個かぶったか

sum2 = 0


for k in range(i):
    for l in range(i):
        if s[k] == s[l]:
            j += 1
            
    if j == 1:
      j = 0
      sum2 += 1
    else:
        temp = s[k]
        for m in range(j):
            s.remove(temp)
        s = [temp]  + s

        i -= (j-1)
        sum2 += j
        j = 0

    if sum2 == n:
      break
          

sum1 = len(s)
print(sum1)


### FIXED CODE ###

n = int(input())
s = []
for _ in range(n):
    s.append(input())

s2 = list(set(s))


print(len(s2))
### BUGGY CODE ###

import numpy as np

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

# n mod 2019 の答えは 0 ~ 2018 のいずれか
# それぞれのmodを取った積のmodでも同じ答えになる


def get_ans():
    # 差が2018以上なら積が0の組み合わせが存在する
    if R - L >= 2018:
        return 0

    # 各値のmodを取ってユニークにする
    # mods = np.mod(np.arange(L, R + 1), 2019)
    mods = np.array([n % 2019 for n in range(L, R + 1)])
    u_mods = np.unique(mods)

    length = len(u_mods)
    # 総当たり
    ans = 2019
    for X in range(length - 1):
        for Y in range(X + 1, length):
            mod = (u_mods[X] * u_mods[Y]) % 2019
            if mod < ans:
                ans = mod
    return ans


print(get_ans())

### FIXED CODE ###

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

# n mod 2019 の答えは 0 ~ 2018 のいずれか
# それぞれのmodを取った積のmodでも同じ答えになる


def get_ans():
    # 差が2018以上なら積が0の組み合わせが存在する
    if R - L >= 2018:
        return 0

    # 総当たり
    ans = 2019
    for X in range(L, R):
        for Y in range(X + 1, R + 1):
            ans = min((ans, (X * Y) % 2019))

    return ans


print(get_ans())
### BUGGY CODE ###

n = int(input())
A = list(map(int,input().split()))
B = []
C = []
for num in A:
    if num in B: 
        C[B.index(num)] += 1
    else:
        B.append(num)
        C.append(1)

if len(B) > 2:
    print('No')
elif len(B) == 1:
    if n == B[0] +1:
        print('Yes')
    elif n//B[0] >= 2:
        print('Yes')
    else:
        print('No')
elif B[0]  == (B[1]+1):
    k = C[1]
    m = B[1]
    if m-k+1 <= 0:
        print('No')
    elif (n-k) % (m-k+1) == 0:
        print('Yes')
    else:
        print('No')
elif B[1] == (B[0]+1):
    k = C[0]
    m = B[0]
    if m-k+1 <= 0:
        print('No')
    elif (n-k) % (m-k+1) == 0:
        print('Yes')
    else:
        print('No')
else:
    print('No')

### FIXED CODE ###

n = int(input())
A = list(map(int,input().split()))
B = []
C = []
for num in A:
    if len(B) >= 3:
        print("No")
        break
    elif num in B: 
        C[B.index(num)] += 1
    else:
        B.append(num)
        C.append(1)


if len(B) >= 3:
    pass
elif len(B) == 1:
    if n == B[0] +1:
        print('Yes')
    elif n//B[0] >= 2:
        print('Yes')
    else:
        print('No')
elif B[0]  == (B[1]+1):
    k = C[1]
    m = B[1]
    if m-k+1 <= 0:
        print('No')
    elif (n-k) % (m-k+1) == 0:
        print('Yes')
    else:
        print('No')
elif B[1] == (B[0]+1):
    k = C[0]
    m = B[0]
    if m-k+1 <= 0:
        print('No')
    elif (n-k) % (m-k+1) == 0:
        print('Yes')
    else:
        print('No')
else:
    print('No')
### BUGGY CODE ###

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

a = list(map(int,input().split()))
r_a = 0
ele = K
expected_value = 0
# 範囲の初めの値と範囲外の値を比較
for i in range(K,N+1):
    if r_a < sum(a[i-K:i]):
        r_a = sum(a[i-K:i])
        ele = i
s_ele = ele-K
for n in range(s_ele,ele):
    expected_value += (a[n]*0.5)+0.5
print(expected_value)


### FIXED CODE ###

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

a = list(map(int,input().split()))
sum_a = [0]

for i in range(K):
    sum_a[0] += a[i]

j = 0

max_v = sum_a[0]
ele = K-1
expected_value = 0
# 範囲の初めの値と範囲外の値を比較
for i in range(K,N):
    sum_a.append(sum_a[j]+(a[i]-a[i-K]))
    if max_v < sum_a[j+1]:
        max_v = sum_a[j+1]
        ele = i
    j += 1
s_ele = ele+1-K
for n in range(s_ele,ele+1):
    expected_value += (a[n]*0.5)+0.5
print(expected_value)
### BUGGY CODE ###

from collections import deque
H,W=map(int,input().split())
Ch,Cw=map(int,input().split())
Dh,Dw=map(int,input().split())
maze=[]

for i in range(H):
  l=list(input())
  for j in range(len(l)):
    if l[j]=='.':l[j]=-1
    if l[j]=='#':l[j]=-2
  maze.append(l)

def isIn(h,w):
  if h<0 or h>=H or w<0 or w >=W:return False
  return True
l=[[Ch-1,Cw-1]]
l=deque(l)
maze[Ch-1][Cw-1]=0
l2=[[0]*W for i in range(H)]

cnt=0
while l:
  cnt+=1
  vectors=[[-1,0],[1,0],[0,1],[0,-1]]

  target=l[0]
  h,w=target
  l.popleft()
  if l2[h][w]:
    continue
  l2[h][w]=1
  for vector in vectors:
    if not isIn(h+vector[0],w+vector[1]):continue
    if maze[h+vector[0]][w+vector[1]]>maze[h][w] or maze[h+vector[0]][w+vector[1]]==-1:
      maze[h+vector[0]][w+vector[1]]=maze[h][w]
      l.appendleft([h+vector[0],w+vector[1]])
  for i in range(25):
    if not isIn(h+i//5-2,w+i%5-2):continue
    if maze[h+i//5-2][w+i%5-2]>maze[h][w] or maze[h+i//5-2][w+i%5-2]==-1:
      maze[h+i//5-2][w+i%5-2]=maze[h][w]+1
      l.append([h+i//5-2,w+i%5-2])
print(maze[Dh-1][Dw-1])


### FIXED CODE ###

from collections import deque
H,W=map(int,input().split())
Ch,Cw=map(int,input().split())
Dh,Dw=map(int,input().split())
maze=[]

for i in range(H):
  l=list(input())
  for j in range(len(l)):
    if l[j]=='.':l[j]=-1
    if l[j]=='#':l[j]=-2
  maze.append(l)

def isIn(h,w):
  if h<0 or h>=H or w<0 or w >=W:return False
  return True
l=[[Ch-1,Cw-1]]
l=deque(l)
maze[Ch-1][Cw-1]=0
l2=[[0]*W for i in range(H)]

cnt=0
while l:
  cnt+=1
  vectors=[[-1,0],[1,0],[0,1],[0,-1]]

  target=l[0]
  h,w=target
  l.popleft()
  if l2[h][w]:
    continue
  l2[h][w]=1
  for vector in vectors:
    if not isIn(h+vector[0],w+vector[1]):continue
    if maze[h+vector[0]][w+vector[1]]>maze[h][w] or maze[h+vector[0]][w+vector[1]]==-1:
      maze[h+vector[0]][w+vector[1]]=maze[h][w]
      l.appendleft([h+vector[0],w+vector[1]])
  for i in range(25):
    if not isIn(h+i//5-2,w+i%5-2):continue
    if maze[h+i//5-2][w+i%5-2]>maze[h][w] or maze[h+i//5-2][w+i%5-2]==-1:
      maze[h+i//5-2][w+i%5-2]=maze[h][w]+1
      l.append([h+i//5-2,w+i%5-2])
print(maze[Dh-1][Dw-1])
### BUGGY CODE ###

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

root = [0]*n
for i in range(m):
    r = list(map(int, input().split()))
    if root[r[0]-1] == 0:
        root[r[0]-1] = [r]
    else:
        root[r[0]-1] = root[r[0]-1]+[r]
    if root[r[1]-1] == 0:
        root[r[1]-1] = [r]
    else:
        root[r[1]-1] = root[r[1]-1]+[r]

kakutei = [1]

answer_li = [0]*n

def dest(r,k):
    if r[0] == k:
        return r[1]
    else:
        return r[0] 

while kakutei:
    k = kakutei.pop(0)
    for r in root[k-1]:
        d = dest(r,k)
        if answer_li[d-1] == 0:
            kakutei.append(d)
            answer_li[d-1] = k

answer_li = answer_li[1:]
if 0 in answer_li:
    print('No')
else:
    print('Yes')
    for i in answer_li:
        print(i)


### FIXED CODE ###

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

root = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    root[a-1].append(b)
    root[b-1].append(a)

kakutei = [1]

answer_li = [0]*n

while kakutei:
    k = kakutei.pop(0)
    for r in root[k-1]:
        if answer_li[r-1] == 0:
            kakutei.append(r)
            answer_li[r-1] = k

answer_li = answer_li[1:]
if 0 in answer_li:
    print('No')
else:
    print('Yes')
    for i in answer_li:
        print(i)
### BUGGY CODE ###

N, Q = map(int, input().split())
S = input()
for i in range(Q):
    l, r = map(int, input().split())
    print(S[l-1:r].count('AC'))


### FIXED CODE ###

N, Q = map(int, input().split())
S = input()
t = S.count('AC')
L = [0]
R = [0]
for i in range(N-1):
    L.append(L[i]+1 if S[i:i+2] == 'AC' else L[i])
    R.append(R[i]+1 if S[N-i-2:N-i] == 'AC' else R[i])
R.reverse()
for i in range(Q):
    l, r = map(int, input().split())
    print(t-L[l-1]-R[r-1])
### BUGGY CODE ###

n = int(input())
A = list(map(int,input().split()))
q = int(input())
M = list(map(int,input().split()))

def solve(i,m):
    a = 0
    if a ==m:
        return True
    if i >= n:
        return False
    
    res = solve(i+1,m) or solve(i+1,m-A[i])
    return res 

for k in M:
    print("yes" if solve(0,k) else "no")
        

### FIXED CODE ###

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

def makeSum(A,i,T):
    if i == len(A):
        T[sum(A)] = 0
    else:
        makeSum(A,i+1,T)
        ret = A[i]
        A[i] = 0
        makeSum(A,i+1,T)
        A[i] = ret

T = {}
makeSum(A,0,T)
for m in M:
    if m in T:
        print("yes")
    else:
        print("no")
### BUGGY CODE ###

L, R = map(int, input().split())
ans = 2019
if R - L >= 2018:
    ans = 0
for i in range(L, R):
    for j in range(i+1, R+1):
        ans = min(ans, (i*j)%2019)

print(ans)

### FIXED CODE ###

L, R = map(int, input().split())
if R - L >= 2018:
	print(0)
else:
	ans = 2019
	for i in range(L, R):
		for j in range(i + 1, R + 1):
			ans = min(ans, i * j % 2019)
	print(ans)
### BUGGY CODE ###

def main():
	a,b,c,d=map(int,input().split())
	mod=998244353
	dp=[[0 for _ in range(d)]for _ in range(c)]
	dp[a-1][b-1]=1
	for i in range(a-1,c):
		for j in range(b-1,d):
			if i!=a-1:
				dp[i][j]+=dp[i-1][j]*(j+1)%mod
			if j!=b-1:
				dp[i][j]+=dp[i][j-1]*(i+1)%mod
			if i!=a-1 and j!=b-1:
				dp[i][j]-=dp[i-1][j-1]*i*j%mod
			dp[i][j]%=mod
	print(dp[-1][-1])

if __name__ == '__main__':
	main()

### FIXED CODE ###

def main():
	a,b,c,d=map(int,input().split())
	mod=998244353
	dp=[[0 for _ in range(d)]for _ in range(c)]
	dp[a-1][b-1]=1
	for i in range(a-1,c):
		for j in range(b-1,d):
			if i!=a-1:
				dp[i][j]+=dp[i-1][j]*(j+1)%mod
			if j!=b-1:
				dp[i][j]+=dp[i][j-1]*(i+1)%mod
			if i!=a-1 and j!=b-1:
				dp[i][j]-=dp[i-1][j-1]*i*j%mod
			dp[i][j]%=mod
	print(dp[-1][-1])

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

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

n,q = map(int,input().split())
t = [[] for _ in range(n+1)]
for _ in range(n-1):
  a,b = map(int,input().split())
  t[a].append(b)
  t[b].append(a)
cnt = [0]*(n+1)
for _ in range(q):
  p,x = map(int,input().split())
  cnt[p] += x
def csum(now,bef):
  for i in t[now]:
    if i != bef:
      cnt[i] += cnt[now]
      csum(i,now)
csum(1,0)
for i in range(1,n+1):
  print(cnt[i],end=" ")

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

n,q = map(int,input().split())
t = [[] for _ in range(n+1)]
for _ in range(n-1):
  a,b = map(int,input().split())
  t[a].append(b)
  t[b].append(a)
cnt = [0]*(n+1)
for _ in range(q):
  p,x = map(int,input().split())
  cnt[p] += x
def csum(now,bef):
  for i in t[now]:
    if i != bef:
      cnt[i] += cnt[now]
      csum(i,now)
csum(1,0)
print(*cnt[1:])
### BUGGY CODE ###

from collections import deque


N , M = map(int,input().split())
ikusa_L = []
for i in range(M):
    ikusa_L.append(list(map(int,input().split())))
ikusa_L.sort(key=lambda x: x[1])
q = deque(ikusa_L)
q_1 = deque(q)
count = 0
while len(q_1) > 0:
    q_1 = deque([])
    a = q.popleft()
    cut = a[1]
    #print(cut,'aa')
    count += 1
    pop_count = 0
    for i in q:
        if not(i[0] < cut):
            q_1.append(i)
    q = deque(q_1)
    #print(q_1)

print(count)

### FIXED CODE ###

from collections import deque


N , M = map(int,input().split())
ikusa_L = []
for i in range(M):
    ikusa_L.append(list(map(int,input().split())))
ikusa_L.sort(key=lambda x: x[1])
q = deque(ikusa_L)
q_1 = deque(q)
count = 0
while len(q_1) > 0:
    q_1 = deque([])
    a = q.popleft()
    cut = a[1]
    #print(cut,'aa')
    count += 1
    pop_count = 0
    for i in q:
        if not(i[0] < cut):
            q_1.append(i)
    q = deque(q_1)
    #print(q_1)

print(count)
### BUGGY CODE ###

def main():
    MOD = 10 ** 9 + 7
    n = int(input())
    a = list(map(int, input().split()))
    lst = [-1] * n

    # O(N)
    for i in range(n + 1):
        if lst[a[i] - 1] != -1:
            first = lst[a[i] - 1]
            second = i
            break
        lst[a[i] - 1] = i

    # print (first, second)    
    left = first
    right = n - second
    # print (left, right)

    N = n + 1
    tmp1 = 1
    tmp2 = 1
    # O(N ^ 2)
    for i in range(1, n + 2):
        tmp1 = (tmp1 * (N + 1 - i))//i
        if i == 1:
            tmp2 = 1
        elif left + right < i - 1:
            tmp2 = 0
        else:
            tmp2 = (tmp2 * (left + right + 1 - (i - 1))) // (i - 1)
        print ((tmp1 - tmp2) % MOD)

if __name__ == '__main__':
    main()

### FIXED CODE ###

MOD = 10 ** 9 + 7
n = int(input())
a = list(map(int, input().split()))
lst = [-1] * n

# O(N)
for i in range(n + 1):
    if lst[a[i] - 1] != -1:
        first = lst[a[i] - 1]
        second = i
        break
    lst[a[i] - 1] = i

# print (first, second)    
left = first
right = n - second

U = 10 ** 5 + 1
def power_mod(a, n):
    if n == 0:
        return 1
    x = power_mod(a//2)

def make_fact(fact, fact_inv):
    for i in range(1, U + 1):
        fact[i] = (fact[i - 1] * i) % MOD
    fact_inv[U] = pow(fact[U], MOD - 2, MOD)
    for i in range(U, 0, -1):
        fact_inv[i - 1] = (fact_inv[i] * i) % MOD

def comb(n, k):
    if k < 0 or n < k:
        return 0
    x = fact[n]
    x *= fact_inv[k]
    x %= MOD
    x *= fact_inv[n - k]
    x %= MOD
    return x

fact = [1] * (U + 1)
fact_inv = [1] * (U + 1)
make_fact(fact, fact_inv)

for i in range(1, n + 2):
    ans = comb(n + 1, i) - comb(left + right, i - 1)
    print (ans % MOD)
### BUGGY CODE ###

from fractions import gcd
K = int(input())

def gcd3(a, b, c):
  x = gcd(a, b)
  y = gcd(x, c)
  return y

ans = 0
#count = 0
for i in range(1, K + 1):
  for j in range(1, K + 1):
    for k in range(1, K + 1):
      #count += 1
      #print(count, gcd3(i, j, k))
      ans += gcd3(i, j, k)

print(ans)  

### FIXED CODE ###

import math
from functools import reduce
K = int(input())

def gcd(*numbers):
  return reduce(math.gcd, numbers)


ans = 0
#count = 0
for i in range(1, K + 1):
  for j in range(i, K + 1):
    for k in range(j, K + 1):
      #count += 1
      #print(count, gcd3(i, j, k))
      x = gcd(i, j, k)
      if i == j:
        if j == k:
          ans += x
        else:
          ans += 3 * x
      else:
        if i == k:
          ans += 3 * x
        elif j == k:
          ans += 3 * x
        else:
          ans += 6 * x
          

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

N=int(input())
A=list(map(int,input().split()))
for i in range(1,N+1):
    print(A.index(i)+1,end=" ")

### FIXED CODE ###

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

d=dict(zip(A,K))

for i in range(1,N+1):
    print(d[i], end=" ")
### BUGGY CODE ###

N, M = [ int(it) for it in input().split() ]
MOD = 1000000007

import math
sM = int(math.sqrt(M)+1)

p_li = []
m = M
for i in range(sM):
  for j in range(2,sM+1):
    if (m%j)==0:
      p_li.append(j)
      m//=j
      break
  if (m==1):
    break
if (m!=1):
  p_li.append(m)
    
    
import collections
co = collections.Counter(p_li)
vec = co.values()

def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m
  
s = 1
for v in vec:
  
  ss = 1
  for i in range(N-1+v,v,-1):
    ss = (ss*i)%MOD
  for i in range(N-1,0,-1):
    ss = (ss*mod_inv(i,MOD))%MOD
  s *= (ss%MOD)
  s = s%MOD
print (s%MOD)
      




### FIXED CODE ###

N, M = [ int(it) for it in input().split() ]
MOD = 1000000007

import math
sM = int(math.sqrt(M)+1)

p_li = []
m = M
for j in range(2,sM+1):
  for i in range(sM):
    if (m%j)==0:
      p_li.append(j)
      m//=j
    else:
      break
  if (m==1):
    break
if (m!=1):
  p_li.append(m)
    
    
import collections
co = collections.Counter(p_li)
vec = co.values()

def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

s = 1
for v in vec:
  X=N-1+v
  Y=N-1
  if (X-Y<Y):
    Y=X-Y
  ss = 1
  sd = 1
  for i in range(X,X-Y,-1):
    ss = (ss*i)%MOD
  for i in range(Y,0,-1):
    sd = (sd*i)%MOD
  
  ss = (ss*mod_inv(sd,MOD))%MOD
  s = (s*ss)%MOD
print (s%MOD)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**7)
n=int(input())
a=list(map(int,input().split()))
d={}
def k(a):
      return ','.join(map(str,a))
def dp(a):
      ka=k(a)
      if ka in d:
            return [d[ka][0],d[ka][1]]
      if len(a)==1:
            d[ka]=[a[0],[]]
            return a[0],[]
      elif len(a)==2:
            d[ka]=[max(a),[min(a)]]
            return max(a),[min(a)]
      else:
            if a[0]-dp(a[1:])[0]>a[-1]-dp(a[:-1])[0]:
                  d[ka]=[a[0],a[1:]]
                  return a[0],a[1:]
            else:
                  d[ka]=[a[-1],a[:-1]]
                  return a[-1],a[:-1]
x,y=0,0
while a!=[]:
      x_,a=dp(a)
      x+=x_
      if a==[]:
            break
      y_,a=dp(a)
      y+=y_
print(x-y)


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
dp=[[0]*n for _ in range(n)]
# dp[i][j]:i<=j,i番目からj番目までの数列(j-i+1個)を前にした時、ゲーム終了までに自分が取れる最大得点。i,j=0,..,n-1
sa=[0]
s=0
for ai in a:
      s+=ai
      sa.append(s)
for len in range(1,n+1):
      for l in range(n-len+1):
            r=l+len-1
            s=sa[r+1]-sa[l]
            dp[l][r]=max(s-dp[l][r-1],s-dp[l+1][r] if l+1<n else 0)
print(2*dp[0][-1]-sa[-1])
### BUGGY CODE ###

import numpy as np
import math

#def get_nearest(point, lst):
#    idx = np.abs(np.asarray(lst) - point).argmin()
#    return lst[idx]

def get_nearest(point, lst):
    idx = np.searchsorted(lst, point, side="left")
    if idx > 0 and (idx == len(lst) or \
            math.fabs(point - lst[idx-1]) < math.fabs(point - lst[idx])):
        return lst[idx-1]
    else:
        return lst[idx]

A, B, Q = [int(x) for x in input().split(" ")]
a = []
b = []
for i in range(A):
    a.append(int(input()))
for i in range(B):
    b.append(int(input()))

for i in range(Q):
    q = int(input())
    nearest_a = get_nearest(q, a)
    nearest_b = get_nearest(q, b)
#   print(q, nearest_a, nearest_b)
    
    if abs(nearest_a - q) < abs(nearest_b - q):
        nearer, farer = nearest_a, nearest_b
        nearer_list, farer_list = a, b
    else:
        nearer, farer = nearest_b, nearest_a
        nearer_list, farer_list = b, a

    nearer_first  = abs(q - nearer)
    nearer_first += abs(nearer - get_nearest(nearer, farer_list))

    farer_first  = abs(q - farer)
    farer_first += abs(farer - get_nearest(farer, nearer_list))

    answer = min(nearer_first, farer_first)

    print(answer)

### FIXED CODE ###

import bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
    x = int(input())
    b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    res = INF
    for S in [s[b - 1], s[b]]:
        for T in [t[d - 1], t[d]]:
            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
            res = min(res, d1, d2)
    print(res)
### BUGGY CODE ###

N = int(input())
D = list(map(int,input().split()))
M = int(input())
T = list(map(int,input().split()))

D = sorted(D)
T = sorted(T)

res = 'YES'
for i in range(M):
    if T[i] in D:
        D.pop(D.index(T[i]))
    else :
        res = 'NO'
        break
print(res)

### FIXED CODE ###

from collections import Counter

N = int(input())
D = list(map(int,input().split()))
M = int(input())
T = list(map(int,input().split()))

res = 'YES'
counter_d = Counter(D)
counter_t = Counter(T)

set_t = list(set(T))
for i in set_t:
    if counter_d[i] < counter_t[i]:
        res = 'NO'
        break

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

from datetime import datetime
K = int(input())
start = datetime.now()
def KSum(n):
    k = 0
    for i in str(n):
        k += int(i)
    return k

m = KSum(K)
j = 1
while((datetime.now()-start).total_seconds()<1.9):
    P = KSum(K*j)
    if m > P:
        m = P
    j += 1

print(m)


### FIXED CODE ###

from collections import deque
K=int(input())
reached=[0 for i in range(K)]
reached[1]=1
dist=[0 for i in range(K)]
q=deque([])
q.append(1)
while(len(q)>0):
    r=q.popleft()
    v=(r+1)%K
    reached[r]=1
    if (reached[v]==0):
        q.append(v)
        dist[v]=dist[r]+1
    v=(r*10)%K
    if (reached[v]==0):
        q.appendleft(v)
        dist[v]=dist[r]
    if (reached[0]==1):
        break
print(dist[0]+1)