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

N = int(input())
A = list(map(int, input().split()))
dp = [0 for _ in range(N)]

A.sort()

for i in range(N):
    if dp[i] < 2:
        p = A[i]
        for j in range(N):
            if A[j]%p == 0 and A[j] >= p:
                dp[j] += 1
cnt = 0
for i in range(N):
    if dp[i] == 1:
        cnt += 1

print(cnt)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
# dp = [0 for _ in range(N)]

# A.sort()

# for i in range(N):
#     if dp[i] < 2:
#         p = A[i]
#         for j in range(N):
#             if dp[j] < 2 and A[j]%p == 0 and A[j] >= p:
#                 dp[j] += 1
# cnt = 0
# for i in range(N):
#     if dp[i] == 1:
#         cnt += 1
M = 10**6  + 5
cnt = [0 for _ in range(M)]
for x in A:
    if cnt[x] != 0:
        cnt[x] = 2
        continue
    i = x
    while i < M:
        cnt[i] += 1
        i += x
ans = 0
for x in A:
    if cnt[x] == 1:
        ans += 1
print(ans)
### BUGGY CODE ###

N, Q = map(int, raw_input().split())
string = raw_input()
a = []
for i in range(Q):
    a.append(map(int, raw_input().split()))
test_dict = {}
for temp in a[:100000]:
    #print(temp)
    str_sub = string[temp[0]-1:temp[1]]
    if test_dict.get(str_sub):
        print(test_dict.get(str_sub))
        continue
    test_dict[str_sub] = str_sub.count('AC')
    print(test_dict[str_sub])

### FIXED CODE ###

N, Q = map(int, raw_input().split())
string = raw_input()
cnt = [0]
for i in range(N):
#    print(i)
#    print(string[i-2:i])
#    if i == 0:
#        cnt.append(0)
#        continue
    if string[i-1:i+1] == 'AC':
        cnt.append(cnt[i]+1)
        continue
    cnt.append(cnt[i])

for j in range(Q):
    #print(j)
    pare = map(int, raw_input().split())
    print(cnt[pare[1]] - cnt[pare[0]])
### BUGGY CODE ###

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

dp = [0]*(w+1)

for _ in range(n):
  wei, v = map(int, input().split())
  dp_1 = dp[:]
  for j in range(w + 1):
    if j - wei >= 0:
      dp[j] = dp_1[j-wei] + v if (dp_1[j-wei] + v) > dp_1[j] else dp[j]
  
print(dp[w])


### FIXED CODE ###

n, w = map(int, input().split())
things = []
things.append([0,0])
things += [list(map(int, input().split())) for _ in range(n)]

dp = [[0 for _ in range(w + 1)] for _ in range(n + 1)]

def do_dp():
  for i,thing in enumerate(things):
    dp_1 = dp[i-1]
    for j in range(1, w + 1):      
      dp[i][j] = dp_1[j-thing[0]] + thing[1]  if (j - thing[0]) >= 0 else dp_1[j]
      dp[i][j] = max(dp[i][j], dp_1[j])

do_dp()
print(dp[n][w])
### BUGGY CODE ###

import itertools
from collections import Counter

N, X, Y = map(int, input().split())

n_iter = itertools.combinations(list(range(1,N+1)), 2)

count_list = []

for i, j in n_iter:
  #1. abs(X - i) + abs(Y - j) + 1
  #2. abs(Y - i) + abs(X - j) + 1
  #3. abs(j - i)
  x = min(
    abs(X - i) + abs(Y - j) + 1,
    abs(Y - i) + abs(X - j) + 1,
    abs(j - i)
  )
  count_list.append(x)

# 要素数の数え上げと取り出し
num_counter = Counter(count_list)
for i in range(1, N):
  if i in num_counter:
    print(num_counter[i])
  else:
    print(0)

### FIXED CODE ###

import itertools

N, X, Y = map(int, input().split())

n_iter = itertools.combinations(list(range(1,N+1)), 2)

count_list = [0]*(N-1)

for i, j in n_iter:
  #1. abs(X - i) + abs(Y - j) + 1
  #2. abs(Y - i) + abs(X - j) + 1
  #3. abs(j - i)
  x = min(
    abs(X - i) + abs(Y - j) + 1,
    abs(Y - i) + abs(X - j) + 1,
    abs(j - i)
  )
  count_list[x-1] += 1

for i in count_list:
  print(i)
### BUGGY CODE ###

import sys
imput=sys.stdin.readline
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
y=[list(map(int,input().split()))[::-1] for i in range(m)]
y.sort()
y=y[::-1]
#print(y)

l=[]
for i in range(m):
    l+=[y[i][0]]*y[i][1]
#print(l)
l=l[:n]
ans=0
#print(a,l)
for i in range(n):
    if i<=len(l)-1:
        ans+=max(a[i],l[i])
    else:
        ans+=a[i]

print(ans)

### FIXED CODE ###

import sys
imput=sys.stdin.readline
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
y=[list(map(int,input().split()))[::-1] for i in range(m)]
y.sort()
y=y[::-1]
#print(y)

l=[]
w=0
for i in range(m):
    w+=y[i][1]
    l+=[y[i][0]]*y[i][1]
    if w>=n:
        break

#print(l)
l=l[:n]
ans=0
#print(a,l)
for i in range(n):
    if i<=len(l)-1:
        ans+=max(a[i],l[i])
    else:
        ans+=a[i]

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

import itertools

n, m = list(map(int, input().split()))
v = []
for i in range(m):
  tpl = tuple(map(int, input().split()))
  v.append(tpl)
  v.append((tpl[1], tpl[0]))

perms = list(itertools.permutations(v, n-1))
c = 0
for i in perms:
  if i[0][0] != 1:
    continue
  visited = []
  for j in range(len(i)-1):
    if i[j][1] != i[j+1][0]:
      break
    visited.append(i[j][0])
    if i[j+1][1] in visited:
      break
  else:
    c += 1
print(c)


### FIXED CODE ###

import itertools

n, m = list(map(int, input().split()))
v = []
for i in range(m):
  tpl = tuple(map(int, input().split()))
  v.append(tpl)
  v.append((tpl[1], tpl[0]))

perms = list(itertools.permutations(range(1, n+1)))
c = 0
for i in perms:
  if i[0] != 1:
    continue
  for j in range(len(i)-1):
    if (i[j], i[j+1]) not in v:
      break
  else:
    c += 1
print(c)
### BUGGY CODE ###

import itertools
n, k = map(int, input().split())
a = list(map(int, input().split()))
M = 10**9 + 7

dp = [[None] * (k + 1) for _ in range(n + 1)]
def dfs(i=0, at=k):
    if dp[i][at] is not None:
        return dp[i][at]

    if i == n:
        r = int(at == 0)
        dp[i][at] = r
        return r

    cnt = 0
    for v in range(a[i] + 1):
        if v > at:
            break
        cnt += dfs(i + 1, at - v)
    dp[i][at] = cnt
    return cnt
#
# print(dfs())
# for v in dp:
#     print(v)

def fm(array):
    return ["*" if v is None else v for v in array]

def mod(v):
    if v >= M:
        return v % M
    return v

def addmod(a, b):
    return mod(a + b)

# for at in range(k + 1):
for i in reversed(range(n + 1)):
    for at in range(k + 1):
        if i == n:
            dp[i][at] = int(at == 0)
            continue
        cnt = 0
        # print(*fm(dp[i]), end=" -> ")
        # for v in range(min(a[i], at) + 1):
        #     cnt += dp[i + 1][at - v]
        # dpcnt = cnt
        cnt = cs[at] - cs[at - min(a[i], at) - 1]
        dp[i][at] = mod(cnt)
        # print(*fm(dp[i]), "@", at - min(a[i], at), "~", at)
        # print(cnt, "@", at - min(a[i], at), "~", at, ":", *fm(dp[i + 1])[at - min(a[i], at):at + 1])
        # print(dpcnt, cnt)
    cs = list(itertools.accumulate(dp[i], addmod)) + [0]
    # print(*cs, "cs")
    # print(*dp[i], "dp")
    # print("-----")
print(dp[0][k] % M)

# for v in dp:
#     print(*fm(v))


### FIXED CODE ###

import itertools
n, k = map(int, input().split())
a = list(map(int, input().split()))
M = 10**9 + 7

dp = [[None] * (k + 1) for _ in range(n + 1)]
def dfs(i=0, at=k):
    if dp[i][at] is not None:
        return dp[i][at]

    if i == n:
        r = int(at == 0)
        dp[i][at] = r
        return r

    cnt = 0
    for v in range(a[i] + 1):
        if v > at:
            break
        cnt += dfs(i + 1, at - v)
    dp[i][at] = cnt
    return cnt
#
# print(dfs())
# for v in dp:
#     print(v)

def fm(array):
    return ["*" if v is None else v for v in array]

def mod(v):
    if v >= M:
        return v % M
    return v

# def addmod(a, b):
#     return mod(a + b)

# for at in range(k + 1):
for i in reversed(range(n + 1)):
    for at in range(k + 1):
        if i == n:
            dp[i][at] = int(at == 0)
            continue
        cnt = 0
        # print(*fm(dp[i]), end=" -> ")
        # for v in range(min(a[i], at) + 1):
        #     cnt += dp[i + 1][at - v]
        # dpcnt = cnt
        cnt = cs[at] - cs[at - min(a[i], at) - 1]
        dp[i][at] = mod(cnt)
        # print(*fm(dp[i]), "@", at - min(a[i], at), "~", at)
        # print(cnt, "@", at - min(a[i], at), "~", at, ":", *fm(dp[i + 1])[at - min(a[i], at):at + 1])
        # print(dpcnt, cnt)
    # cs = list(itertools.accumulate(dp[i], func=addmod)) + [0]
    cs = list(itertools.accumulate(dp[i])) + [0]
    cs = [mod(v) for v in cs]
    # print(*cs, "cs")
    # print(*dp[i], "dp")
    # print("-----")
print(dp[0][k] % M)

# for v in dp:
#     print(*fm(v))
### BUGGY CODE ###

N = int(input())
a = list(map(int, input().split()))
even_a = [i for i in a if i%2==0]
even_a.sort()
num = len(even_a)
count = 0

if num == 0:
    print(0)
    exit()

i = 0
while even_a[i] % 2 == 0:
    even_a[i] //= 2
    count += 1
    for j in range(i+1, num):
        even_a[j] *= 3
    if even_a[i] % 2 != 0:
        i += 1
    if i == num:
        break

print(count)

### FIXED CODE ###

N = int(input())
a = list(map(int, input().split()))
count = 0

for i in a:
    while i % 2 == 0:
        i //= 2
        count += 1

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

import sys
input = sys.stdin.readline

H,W = map(int,input().split())
q = []
visited = [[True]*(W+2)]
visited += [[True] + [x == '#' for x in input().rstrip()] + [True] for _ in range(H)]
visited.append([True]*(W+2))
  
for i in range(1,H+1):
  for j in range(1,W+1):
    if visited[i][j]:
      q.append((i,j))

ans = -1
while q:
  qq = []
  ans += 1
  for x,y in q:
    if not visited[x-1][y]:
      visited[x-1][y] = True
      qq.append((x-1,y))
    if not visited[x+1][y]:
      visited[x+1][y] = True
      qq.append((x+1,y))
    if not visited[x][y-1]:
      visited[x][y-1] = True
      qq.append((x,y-1))
    if not visited[x][y+1]:
      visited[x][y+1] = True
      qq.append((x,y+1))
  q = qq
  
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline

H, W = map(int, input().split())
G = [[i for i in input()] for j in range(H)]

ls = []
dp = [[-1 for i in range(W)] for j in range(H)]
for h in range(H):
    for w in range(W):
        if G[h][w] == "#":
            ls.append([h,w])
            dp[h][w] = 1

ans = -1
while len(ls) > 0:
    ans += 1
    temp = []
    for h, w in ls:
        if 0 <= h+1 <= H-1 and dp[h+1][w] == -1:
            dp[h+1][w] = 1
            temp.append([h+1,w])
        if 0 <= h-1 <= H-1 and dp[h-1][w] == -1:
            dp[h-1][w] = 1
            temp.append([h-1,w])
        if 0 <= w+1 <= W-1 and dp[h][w+1] == -1:
            dp[h][w+1] = 1
            temp.append([h,w+1])
        if 0 <= w-1 <= W-1 and dp[h][w-1] == -1:
            dp[h][w-1] = 1
            temp.append([h,w-1])
    ls = temp

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

def is_prime(x):
  res = 1
  y = int(x**0.5)
  for i in range(2,y+1):
    if x%i==0:
      res = 0
      break
  return res

prime = []
for i in range(10**5+2):
  if i<2 or i%2==0:
    prime.append(0)
  else:
    if is_prime(i)==1 and is_prime((i+1)/2)==1:
      prime.append(1)
    else:
      prime.append(0)
#input
Q = int(input())
ans = []
for i in range(Q):
  l,r = map(int,input().split())
  ans.append(sum(prime[l:r+1]))
for a in ans:
  print(a)

### FIXED CODE ###

def is_like2017(X):
  res = 1
  for x in [X,(X+1)/2]:
    y = int(x**0.5)
    for i in range(2,y+1):
      if x%i==0:
        res=0
        break
    if res==0:
      break
  return res

prime_accumulation = []
for i in range(10**5+2):
  if i<2:
    prime_accumulation.append(0)
  elif i%2==0:
    prime_accumulation.append(prime_accumulation[i-1])
  else:
    if is_like2017(i)==1:
      prime_accumulation.append(prime_accumulation[i-1]+1)
    else:
      prime_accumulation.append(prime_accumulation[i-1])

#input
Q = int(input())
ans = []
for i in range(Q):
  l,r = map(int,input().split())
  print(prime_accumulation[r]-prime_accumulation[l-1])
### BUGGY CODE ###

k=int(input())
a=[1,2,3,4,5,6,7,8,9]
ans=a[:]
if k<=9:
  print(ans[k-1])
  exit()
k-=9
for i in range(9):
  b=[0 for _ in range(9*10**(i+1))]
  ind=0
  for x in a:
    d=x%10
    if d!=9 and d!=0:
      b[ind]=x*10+d-1
      b[ind+1]=x*10+d
      b[ind+2]=x*10+d+1
      ind+=3
    elif d==0:
      b[ind]=x*10+d
      b[ind+1]=x*10+d+1
      ind+=2
    elif d==9:
      b[ind]=x*10+d-1
      b[ind+1]=x*10+d
      ind+=2
  b=b[:ind]
  if len(b)>=k:
    print(b[k-1])
    exit()
  else:
    k-=len(b)
  a=b[:]


### FIXED CODE ###

from collections import deque

k=int(input())
ans=deque([1,2,3,4,5,6,7,8,9])
if k<=9:
  print(ans[k-1])
  exit()
k-=9
while True:
  x=ans.popleft()
  r=x%10
  if r==0:
    q=x*10
    ans.append(q)
    k-=1
    if k==0:
      print(q)
      exit()
    q+=1
    ans.append(q)
    k-=1
    if k==0:
      print(q)
      exit()
  elif r!=0 and r!=9:
    q=x*10+r-1
    ans.append(q)
    k-=1
    if k==0:
      print(q)
      exit()
    q+=1
    ans.append(q)
    k-=1
    if k==0:
      print(q)
      exit()
    q+=1
    ans.append(q)
    k-=1
    if k==0:
      print(q)
      exit()
  elif r==9:
    q=x*10-1+r
    ans.append(q)
    k-=1
    if k==0:
      print(q)
      exit()
    q+=1
    ans.append(q)
    k-=1
    if k==0:
      print(q)
      exit()
### BUGGY CODE ###

from sys import stdin
from math import isinf

readline = stdin.readline


min_cost = float('inf')


def main():
    v, e = map(int, readline().split())
    g = [[float('inf')] * v for _ in range(v)]
    for _ in range(e):
        s, t, d = map(int, readline().split())
        g[s][t] = d
    dfs(g, 0, 0, set(range(1, v)))
    global min_cost
    print(-1 if isinf(min_cost) else min_cost)


def dfs(g, cost, last, vs):
    global min_cost
    if min_cost < cost:
        return
    if vs:
        for v in vs:
            if isinf(g[last][v]):
                continue
            dfs(g, cost + g[last][v], v, vs - {v})
    elif min_cost > cost + g[last][0]:
        min_cost = cost + g[last][0]

main()

### FIXED CODE ###

# http://www.geocities.jp/m_hiroi/light/pyalgo65.html

def memoize(f):
    table = {}
    def func(*args):
        if not args in table:
            table[args] = f(*args)
        return table[args]
    return func

@memoize
def tsp(p, v):
    if (1 << point_size) - 1 == v:
        return distance_table[p][0]
    else:
        return min(distance_table[p][x] + tsp(x, v | (1 << x)) for x in range(point_size) if not (v & (1 << x)))

from sys import stdin
from collections import defaultdict
from math import isinf

readline = stdin.readline

point_size, e = map(int, readline().split())
distance_table = [[float('inf')] * point_size for _ in range(point_size)]
for _ in range(e):
    s, t, d = map(int, readline().split())
    distance_table[s][t] = d
ans = tsp(0,1)
print(-1 if isinf(ans) else ans)
### BUGGY CODE ###

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

li = []
is1s = False
if s[0] == "1":
    is1s = True
cnt0 = 0
cnt1 = 0
for i in range(len(s)):
    if s[i] == "0" :
        cnt0 += 1
    if s[i] == "1":
        cnt1 += 1
    if i >= 1:
        if s[i] == "0" and s[i-1] == "1":
            li.append(cnt1)
            cnt1 = 0
        if s[i] == "1" and s[i-1] == "0": 
            li.append(cnt0)
            cnt0 = 0

if (cnt1 > 0):
    li.append(cnt1)
if (cnt0 > 0):
    li.append(cnt0)
pivot = 2 * k 
sumlist = []
for i in range(len(li)):
    sumlist.append(sum(li[i:len(li)]))
sumlist.append(0)
anslist=[]
if(is1s):
    for i in range(len(li)):
        if(i % 2 == 0):
            tmp = sumlist[i] - sumlist[min(len(li), i+pivot+1)]
            anslist.append(tmp)
else:
    for i in range(len(li)):
        if(i % 2 == 1):
            tmp = sumlist[i] - sumlist[min(len(li), i+pivot+1)]
            anslist.append(tmp)
    anslist.append(sumlist[0] - sumlist[min(len(li), pivot)])

print(max(anslist))



### FIXED CODE ###

import numpy as np
n,k = map(int,input().split())	
s=list(input())	

li = []
is1s = False
if s[0] == "1":
    is1s = True
cnt0 = 0
cnt1 = 0
for i in range(len(s)):
    if s[i] == "0" :
        cnt0 += 1
    elif s[i] == "1":
        cnt1 += 1
    if i >= 1:
        if s[i] == "0" and s[i-1] == "1":
            li.append(cnt1)
            cnt1 = 0
        elif s[i] == "1" and s[i-1] == "0": 
            li.append(cnt0)
            cnt0 = 0

if (cnt1 > 0):
    li.append(cnt1)
if (cnt0 > 0):
    li.append(cnt0)
pivot = 2 * k 
li = np.array(li)
anslist=[]
if(is1s):
    for i in range(len(li)):
        if(i % 2 == 0):
            tmp = np.sum(li[i:min(len(li), i+pivot+1)])
            anslist.append(tmp)
else:
    for i in range(len(li)):
        if(i % 2 == 1):
            tmp = np.sum(li[i:min(len(li), i+pivot+1)])
            anslist.append(tmp)
    anslist.append(sum(li[0:pivot]))

print(max(anslist))
### BUGGY CODE ###

n=int(input())
lst=list(map(int,input().split()))
total=0
for i in range(n):
  for j in range(i+1, n):
    total+=lst[i]*lst[j]
print(total%(10**9+7))

### FIXED CODE ###

n=int(input())
lst=list(map(int,input().split()))
total=0
temp=0
for i in range(1, n):
  temp+=lst[i]
for j in range(n-1):
  total+=lst[j]*temp
  temp-=lst[j+1]
print(total%(10**9+7))
### BUGGY CODE ###

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

for a in A:
    ans = ans*a

if ans > 10**18:
    ans=-1

print(ans)

### FIXED CODE ###

import sys
n = input()
list_num =list(map(int,input().split()))
output = 1
if 0 in list_num:
    print(0)
    sys.exit()
for i in list_num:
    output = output * i
    if output > 10 ** 18:
        print(-1)
        sys.exit()
print(output)
### BUGGY CODE ###

s = str(input())
cnt = 0
prev = len(s)
while len(s) > 1:
    for i in range(len(s) - 1):
        if (s[i] == '0' and s[i + 1] == '1') or (s[i] == '1' and s[i + 1] == '0'):
            cnt += 2
            s = s[:i] + 'xx' + s[i + 2:]
    s = s.replace('xx', '')
    if len(s) == prev:
        break
    prev = len(s)
print(cnt)


### FIXED CODE ###

s = str(input())
cnt = 0
prev = s[0]
stock = 1
for i in range(1, len(s)):
    if stock == 0:
        prev = s[i]
        stock += 1
    else:
        if s[i] != prev:
            cnt += 2
            stock -= 1
            if stock > 0:
                if s[i] == '0':
                    prev = '1'
                else:
                    prev = '0'
        else:
            prev = s[i]
            stock += 1
print(cnt)
### BUGGY CODE ###

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

from pprint import pprint

l=[[False for _ in range(n)] for _ in range(n)]
v=[True for _ in range(n)]
for a,b in ab:
    l[b-1][a-1], l[a-1][b-1]=True,True

def dfs(x,t,v,j,m,n):
    j+=1
    if j<=m:
        v[x]=False
        for i in range(1,n):
            if t[x][i]:
                dfs(i,t,v,j,m,n)
import copy

ans=0
for i in range(m):
    j=0
    t=copy.deepcopy(l)
    t[ab[i][1]-1][ab[i][0]-1],t[ab[i][0]-1][ab[i][1]-1]=False,False
    v=[True for _ in range(n)]
    if i!=0:
        dfs(ab[0][0]-1, t, v, j, m,n)
    else:
        dfs(ab[1][0]-1, t, v, j, m,n)
        
    z=False
    for x in v:
        if x:
            z=True
    if z:
        ans+=1
print(ans)

### FIXED CODE ###

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

from pprint import pprint

l=[[False for _ in range(n)] for _ in range(n)]
v=[True for _ in range(n)]
for a,b in ab:
    l[b-1][a-1], l[a-1][b-1]=True,True
def dfs(x,t,v,j,m,n):
    j+=1
    if j<n+m:
        v[x]=False
        for i in range(1,n):
            if v[i]:
                if t[x][i]:
                    dfs(i,t,v,j,m,n)
import copy

ans=0
for i in range(m):
    j=0
    t=copy.deepcopy(l)
    t[ab[i][1]-1][ab[i][0]-1],t[ab[i][0]-1][ab[i][1]-1]=False,False
    v=[True for _ in range(n)]
    dfs(0, t, v, j, m,n)
        
    z=False
    for x in v:
        if x:
            z=True
    if z:
        ans+=1
print(ans)
### BUGGY CODE ###

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

judge = 0

if n%k==0:
    judge = 1
    print(0)
if judge == 0:
    while n>= 0:
        n -= k

    if abs(n+k)<abs(n):
        print(abs(n+k))
    else:
        print(abs(n))

### FIXED CODE ###

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

n = n%k

if n<abs(n-k):
    print(n)
else:
    print(abs(n-k))
### BUGGY CODE ###

from collections import deque

S = deque(input())
Q = int(input())
for _ in range(Q):
    q = input().split()
    if q[0] == '1':
        S.reverse()
    else:
        if q[1] == '1':
            S.appendleft(q[2])
        else:
            S.append(q[2])

print(''.join(S))


### FIXED CODE ###

from collections import deque

S = deque(input())
Q = int(input())
rev = False
for _ in range(Q):
    q = input().split()
    if q[0] == '1':
        rev = not rev
    else:
        if q[1] == '1':
            if rev:
                S.append(q[2])
            else:
                S.appendleft(q[2])
        else:
            if rev:
                S.appendleft(q[2])
            else:
                S.append(q[2])
if rev:
    S.reverse()

print(''.join(S))
### BUGGY CODE ###

import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))
# map(int, input().split())
# int(input())
# input().split()
# mojiretu = ','.join(str_list)
# sorted(input())

n = int(input())
t = input()
p = t[0]
ans = 0
s = t[0]
# 連続4文字以上を圧縮
for x in t[1:]:
    if x == p:
        ans += 1
        if ans < 4:
            s += x
    else:
        ans = 1
        s += x

ans = 0
for t in range(1000):
    q = str(int(t/100))
    if not q in s:
        continue
    z = s.index(q) + 1
    p = deque([int((t%100 - t%10)/10), t%10, -1])
    q = p.popleft()
    for x in s[z:]:
        if q == int(x):
            q = p.popleft()
        if q == -1:
            ans += 1
            break
    else:
        if q == -1:
            ans += 1
print(ans)


### FIXED CODE ###

import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))
# map(int, input().split())
# int(input())
# input().split()
# mojiretu = ','.join(str_list)
# sorted(input())

n = int(input())
s = input()
cnt = 0
q = s[0]
t = s[0]
for x in s[1:]:
    if x == q:
        cnt += 1
        if cnt < 3:
            t += x
    else:
        cnt = 0
        t += x
        q = x
ans = 0
for i in range(10):
    x = t.find(str(i)) + 1
    if not x: continue
    for j in range(10):
        y = t[x:].find(str(j)) + 1
        if not y: continue
        for k in range(10):
            z = t[x + y:].find(str(k)) + 1
            if not z: continue
            #print(i,j,k, ':', x,y,z)
            ans += 1
print(ans)
### BUGGY CODE ###

n = int(input())
ls = [int(input()) for _ in range(n)]
ls.reverse()

result = []
for i in range(n-1):
    result.append(ls[i] - min(ls[i+1:]))

print(max(result))


### FIXED CODE ###

n = int(input())
m = [int(input()) for _ in range(n)]

def fx(raw):
    min_n = raw[0]
    max_n = raw[1] - raw[0]
    for i in raw[1:]:
        if i - min_n >= max_n:
            max_n = i - min_n
        if i < min_n:
            min_n = i
    return max_n


if __name__ == '__main__':
    print(fx(m))