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

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

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

# N-1 .. 0
cnum = 1
for i in range(N-1,0,-1):
    #print(A[:i])
    #print(A[i])
    if sum(A[:i]) * 2 < A[i]:
        break
    else:
        cnum += 1
print(cnum)


### FIXED CODE ###

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

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

# N-1 .. 0
cnum = 1
for i in range(N-1,0,-1):
    sumA -= A[i]
    if sumA * 2 < A[i]:
        break
    else:
        cnum += 1
print(cnum)
### BUGGY CODE ###

from collections import deque

h,w = map(int,input().split())
ch,cw = map(int,input().split())
dh,dw = map(int,input().split())

g = []
for i in range(h):
  s = list(input())
  g.append(s)
inf = float("inf")
dist = [[inf]*w for i in range(h)]
queue = deque()
start = [ch-1,cw-1,0]
queue.append(start)
while queue:
    y, x,wapu = queue.popleft()
    if dist[y][x]<wapu:
      continue
    dist[y][x] = wapu
    for new_y, new_x in ([y+1, x], [y-1, x], [y, x+1], [y, x-1]):
        if 0 <= new_y <= h-1 and 0 <= new_x <= w-1:
            if g[new_y][new_x] == '#':
                continue           
            elif wapu < dist[new_y][new_x]:
                dist[new_y][new_x] = wapu
                queue.append([new_y, new_x,wapu])
    for new_y, new_x in ([y+1, x+1], [y+1, x-1], [y-1, x+1], [y-1, x-1], [y+2, x-1], [y-2, x-1], [y-2, x], [y+2, x], [y+2, x+1], [y-2, x+1], [y-1, x+2], [y, x+2], [y+1, x+2], [y+2, x+2], [y-2, x-2], [y-2, x+2], [y+2, x-2], [y-1, x-2], [y, x-2], [y+1, x-2]):
      if 0 <= new_y <= h-1 and 0 <= new_x <= w-1:
            if g[new_y][new_x] == '#':
                continue       
            else:
                 new_wapu= wapu +1
            if new_wapu < dist[new_y][new_x]:
                dist[new_y][new_x] = new_wapu
                queue.append([new_y, new_x,new_wapu])

ans = dist[dh-1][dw-1]
if ans == inf:
  print(-1)
else:
  print(dist[dh-1][dw-1])


### FIXED CODE ###

from collections import deque


H, W = map(int, input().split())
Ch, Cw = map(lambda x: int(x) - 1, input().split())
Dh, Dw = map(lambda x: int(x) - 1, input().split())
maze = [input() for _ in range(H)]

INF = 10 ** 12
path = [[INF] * W for _ in range(H)]  # path: 各マスへの移動コスト

# walk:移動A, warp:移動B
walk = [(0, 1), (0, -1), (-1, 0), (1, 0)]
warp = [(i, j) for i in range(-2, 3) for j in range(-2, 3) if (i, j) not in [(0, 0)] + walk]

q = deque()
path[Ch][Cw] = 0
q.append((Ch, Cw, 0))

while q:
    x, y, s = q.popleft()
    for dx, dy in walk:  # 移動A
        nx = x + dx
        ny = y + dy
        if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] == '.' and path[nx][ny] > s:
            path[nx][ny] = s
            q.appendleft((nx, ny, s))  # 移動Aの場合はコスト0. キューの先頭に追加する.
    for dx, dy in warp:  # 移動B
        nx = x + dx
        ny = y + dy
        if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] == '.' and path[nx][ny] > s + 1:
            path[nx][ny] = s + 1
            q.append((nx, ny, s + 1))  # 移動Bの場合はコスト1. キューの最後尾に追加する.
    
ans = path[Dh][Dw] if path[Dh][Dw] < INF else '-1'
print(ans)
### BUGGY CODE ###

from collections import deque

s = input()
q = int(input())
ls = [input().split() for _ in range(q)]

ans = deque(s)

for t in ls:
    if t[0] == '1':
        ans.reverse()
    elif t[0] == '2':
        if t[1] == '1':
            ans.appendleft(t[2])
        elif t[1] == '2':
            ans.append(t[2])

l = list(ans)

print("".join(ans))

### FIXED CODE ###

from collections import deque

s = input()
q = int(input())
ls = [input().split() for _ in range(q)]

ans = deque(s)
cnt = 0

for t in ls:
    if t[0] == '1':
        cnt += 1
    elif t[0] == '2':
        if cnt % 2 == 0:
            if t[1] == '1':
                ans.appendleft(t[2])
            elif t[1] == '2':
                ans.append(t[2])
        elif cnt % 2 == 1:
            if t[1] == '1':
                ans.append(t[2])
            elif t[1] == '2':
                ans.appendleft(t[2])

if cnt % 2 == 0:
    print("".join(ans))
elif cnt % 2 == 1:
    ans.reverse()
    print("".join(ans))
### BUGGY CODE ###

import sys
input = sys.stdin.readline

N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
         
n = [1, 1]
cnt = 2
while cnt!=N+1:
    if cnt-1 in a:n[1]=0
    n[0], n[1] = n[1], n[0]+n[1] 
    cnt += 1
    if n[1]==0:break

print(n[-1]%(10**9+7))

### FIXED CODE ###

import sys
input = sys.stdin.readline

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

broken= [False]*(N+1)
for i in range(M):
    broken[int(input())] = True

dp = [0]*(N+1)
dp[0] = 1
if not broken[1]:dp[1] = 1

         
for i in range(2, N+1):
    if broken[i]:continue
    dp[i] = dp[i-1] + dp[i-2]
    dp[i] %= (10**9 + 7)
print(dp[N])
### BUGGY CODE ###

N, M = map(int, input().strip().split(" "))

edge = []

for m in range(M):
    a, b = map(int, input().strip().split(" "))
    if (a == 1 or a == N) or (b == 1 or b == N):
        edge.append((a, b))

res = False
for n in range(N):
    if len([e for e in edge if e[0] == 1 and e[1] == n]) > 0 and len([e for e in edge if e[0] == n and e[1] == N]) > 0:
        print("POSSIBLE")
        res = True
        break


if not res:
    print("IMPOSSIBLE")


### FIXED CODE ###

N, M = map(int, input().strip().split(" "))

to_one = [False] * N
to_N = [False] * N
for m in range(M):
    a, b = map(int, input().strip().split(" "))
    if a == 1:
        to_one[b] = True
    if b == N:
        to_N[a] = True

res = False
for n in range(2, N):
    if to_N[n] and to_one[n]:
        print("POSSIBLE")
        res = True
        break

if not res:
    print("IMPOSSIBLE")
### BUGGY CODE ###

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


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
ans=1
yn=0
if a.count(0)!=0:
    print(0)
else:
    for i in range(n):
        ans*=a[i]
        if ans>10**18:
            yn=1
            break
    if yn==1:
        print(-1)
    else:
        print(ans)
### BUGGY CODE ###

#import random

def putmx(lis):
  ret=[]
  mx=max(lis)
  for i in range(len(lis)):
    if mx==lis[i]:
      ret.append(i)
  return ret
  

h,w,m=map(int,input().split())
hb=[0]*h
wb=[0]*w
bmb=[]
for i in range(h):
  bmb.append([])
for i in range(m):
  hh,ww=map(int,input().split())
  hh-=1
  ww-=1
  bmb[hh].append(ww)
  hb[hh]+=1
  wb[ww]+=1

hmx=putmx(hb)
wmx=putmx(wb)
mhb=max(hb)
mwb=max(wb)
#print(hb,wb,hmx,wmx)
fl=False
for i in hmx:
  for j in wmx:
    if not j in bmb[i]:
      print(mhb+mwb)
      fl=True
      break
  if fl:
    break
else:
  print(mhb+mwb-1)



### FIXED CODE ###

#import random

def putmx(lis,mx):
  ret=[]
  for (i,j) in zip(range(len(lis)),lis):
    if j==mx:
      ret.append(i)
  return ret
  

h,w,m=map(int,input().split())
hb=[0]*h
wb=[0]*w
bmb=[]
for i in range(h):
  bmb.append({-1})
for i in range(m):
  hh,ww=map(int,input().split())
  hh-=1
  ww-=1
  bmb[hh].add(ww)
  hb[hh]+=1
  wb[ww]+=1
mhb=max(hb)
mwb=max(wb)
hmx=putmx(hb,mhb)
wmx=set(putmx(wb,mwb))

#print(hb,wb,hmx,wmx)
fl=False
for i in hmx:
  if wmx|bmb[i]!=bmb[i]:
    print(mhb+mwb)
    break
else:
  print(mhb+mwb-1)

#print(hmx,wmx,bmb)
### BUGGY CODE ###

# python3

#===============================================================================
from collections import defaultdict, Counter
from functools import lru_cache
from heapq import heappush, heappop
from math import gcd, floor, ceil
from sys import stdin, stdout

def ilist():
    return [int(x) for x in stdin.readline().strip().split(" ")]
def iint():
    return int(stdin.readline().strip())
def istr():
    return stdin.readline().strip()
##==============================================================================


def solve(X):
    B = 0
    while True:
        x1 = X + (B) ** 5
        A = int(x1 ** (1/5.0))
        if A ** 5 == x1:
            return str(A) + " " + str(B)
        x2 = X + (-B) ** 5
        A = int(x1 ** (1/5.0))
        if A ** 5 == x2:
            return str(A) + " " + str(-B)
        B += 1


if __name__ == '__main__':
    X = iint()
    print(solve(X))


### FIXED CODE ###

# python3

#===============================================================================
from collections import defaultdict, Counter
from functools import lru_cache
from heapq import heappush, heappop
from math import gcd, floor, ceil
from sys import stdin, stdout

def ilist():
    return [int(x) for x in stdin.readline().strip().split(" ")]
def iint():
    return int(stdin.readline().strip())
def istr():
    return stdin.readline().strip()
##==============================================================================


def solve(X):
    c = {}
    for i in range(1000):
        c[i] = i ** 5
        c[-i] = -c[i]
    for i in c:
        for j in c:
            if c[i] - c[j] == X:
                return str(i) + " " + str(j)


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


#素因数分解
def prime_factorization(N):
    n=N
    a=2
    prime_factor=[]
    while a**2<=n:
        while n%a==0:
            prime_factor.append(a)
            n//=a
        a+=1
    if n>1:
        prime_factor.append(n)
    return prime_factor


N=int(input())

a=1
b=N//a
dis=abs(a-b)

Li=prime_factorization(N)
# print(Li)

for p in range(2**len(Li)):
    bit=[]
    for e in range(len(Li)):
        if (p>>e)&1==1:
            bit.append(1)
        else:
            bit.append(0)
    # print(bit)
        proindex=[]
        for _ in range(len(bit)):
            if bit[_] ==1:
                proindex.append(_)
        _a=1
        for j in range(len(Li)):
            if proindex.count(j)==1:
                _a*=Li[j]
        _b=N//_a
        _dis=abs(_a-_b)
        if _dis<dis:
            a=_a
            b=_b
            dis=_dis
# print(a,b)
print(a-1+b-1)

### FIXED CODE ###

N=int(input())

a=1
b=N//a
dis=abs(b-a)

for i in range(1,int(N**0.5)+1):
    if N%i==0:
        _a=i
        _b=N//i
        _dis=abs(_b-_a)
        if _dis<dis:
            a=_a
            b=_b
            dis=_dis

print(a-1+b-1)
### BUGGY CODE ###

h, n = map(int, input().split())
a = []
b = []
for i in range(n):
    a_, b_ = map(int, input().split())
    a.append(a_)
    b.append(b_)

dp = [10**9] * (h+1)
dp[0] = 0

for i in range(1, h+1):
    for j in range(n):
        dp[i] = min(dp[i], dp[max(i-a[j], 0)] + b[j])

print(dp[-1])

### FIXED CODE ###

h, n = map(int, input().split())
a = []
b = []
for i in range(n):
    a_, b_ = map(int, input().split())
    a.append(a_)
    b.append(b_)

dp = [10**9] * (h+1)
dp[0] = 0

for i in range(1, h+1):
    for j in range(n):
        dp[i] = min(dp[i], dp[max(i-a[j], 0)] + b[j])

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

n=int(input())
a=sorted([[i]+list(map(int,input().split()))for i in range(n)],key=lambda x:x[1])
s=[]
for i in range(n-1):
    s.append((a[i+1][1]-a[i][1],a[i][0],a[i+1][0]))
a=sorted(a,key=lambda x:x[2])
for i in range(n-1):
    s.append((a[i+1][2]-a[i][2],a[i][0],a[i+1][0]))
s.sort()
t=[i for i in range(n)]
def f(x):
    if x==t[x]:
        return x
    x=t[x]
    return f(t[x])
c=0
for i,j,h in s:
    j,h=f(j),f(h)
    if h!=j:
        t[j]=h
        c+=i
print(c)

### FIXED CODE ###

n=int(input())
a=sorted([[i]+list(map(int,input().split()))for i in range(n)],key=lambda x:x[1])
s=[]
for i in range(n-1):
    s.append((a[i+1][1]-a[i][1],a[i][0],a[i+1][0]))
a=sorted(a,key=lambda x:x[2])
for i in range(n-1):
    s.append((a[i+1][2]-a[i][2],a[i][0],a[i+1][0]))
s.sort()
t=[i for i in range(n)]
def f(x):
    if x==t[x]:
        return x
    t[x]=f(t[x])
    return f(t[x])
c=0
for i,j,h in s:
    j,h=f(j),f(h)
    if h!=j:
        t[j]=h
        c+=i
print(c)
### BUGGY CODE ###

import operator
import functools

def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))
    p  = 0

    for i in range(K-1,N):
        lst= A[i-K+1:i+1]
        p = sum(lst)
        #p = mul(lst)
        #p = functools.reduce(operator.mul,lst)
        if i != K-1:
            if p <= prev:
                print('No')
            else:
                print('Yes')
        prev = p
    
if __name__ == "__main__":
    main()
    

### FIXED CODE ###

def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))
    p  = 0
 
    for i in range(K-1,N):
        #lst= A[i-K+1:i+1]
        #p = sum(lst)
        #p = mul(lst)
        #p = functools.reduce(operator.mul,lst)
        if i != K-1:
            if A[i] <= A[i-K]:
                print('No')
            else:
                print('Yes')
        
    
if __name__ == "__main__":
    main()
### BUGGY CODE ###

import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    A = [-1] * N
    ans = 0
    for _ in range(N):
        n = int(input())
        for i, a in enumerate(A):
            if n > a:
                A[i] = n
                ans = max(ans, i)
                break

    return ans + 1


if __name__ == '__main__':
    print(main())


### FIXED CODE ###

import sys
from collections import deque
from bisect import bisect_left

def main():
    input = sys.stdin.readline
    N = int(input())
    a = int(input())
    q = deque()
    q.append(a)
    ans = 1
    for _ in range(N-1):
        n = int(input())
        if n <= q[0]:
            q.appendleft(n)
            ans += 1
            continue

        if n > q[-1]:
            q[-1] = n
            continue

        pos = bisect_left(q, n)
        q[pos-1] = n
        min_ = q[0]

    return ans


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

n,k=map(int,input().split())
sushi=[]
for i in range(n):
    sushi.append([])
for i in range(n):
    t,d=map(int,input().split())
    sushi[t-1].append(d)
Max=[]
Rest=[]
v=0
for i in sushi:
    if not i==[]:
        Max.append(max(i))
        i.remove(max(i))
        Rest=Rest+i
        v=v+1
Max.sort(reverse=True)
Rest.sort(reverse=True)
Max_s=[]
Rest_s=[0]
Sum=0
for i in Max:
    Sum=Sum+i
    Max_s.append(Sum)
Sum=0
l_r=0
for i in Rest:
    Sum=Sum+i
    Rest_s.append(Sum)
    l_r=l_r+1
ans=0
for i in range(1,min(k,v)+1):
    if k-i<=l_r:
        temp=Max_s[i-1]+Rest_s[k-i]+i**2
        if ans<temp:
            ans=temp
print(ans)


### FIXED CODE ###

n,k=map(int,input().split())
sushi=[]
for i in range(n):
    sushi.append([])
for i in range(n):
    t,d=map(int,input().split())
    sushi[t-1].append(d)
Max=[]
Rest=[]
v=0
for i in sushi:
    if not i==[]:
        Max.append(max(i))
        i.remove(max(i))
        for j in i:
            Rest.append(j)
        v=v+1
Max.sort(reverse=True)
Rest.sort(reverse=True)
Max_s=[]
Rest_s=[0]
Sum=0
for i in Max:
    Sum=Sum+i
    Max_s.append(Sum)
Sum=0
l_r=0
for i in Rest:
    Sum=Sum+i
    Rest_s.append(Sum)
    l_r=l_r+1
ans=0
for i in range(1,min(k,v)+1):
    if k-i<=l_r:
        temp=Max_s[i-1]+Rest_s[k-i]+i**2
        if ans<temp:
            ans=temp
print(ans)
### BUGGY CODE ###


MOD = 10**9 + 7

S = input()
L = len(S)
memo = [[0 for i in range(14)] for j in range(L + 1)]
dp = [[0 for i in range(14)] for j in range(L + 1)]

dp[0][0] = 1

for k in range(L):
    for m in range(13):
        # print('S[-(k+1)]', S[-(k+1)], 'm', m)
        if S[-(k+1)] == '?':
            for i in range(10):
                dp[k+1][(m + (10 ** k * i) % 13) % 13] += dp[k][m]
                # print('dp[k+1][(m + (10 ** k + i) % 13) % 13]', dp[k+1][(m + (10 ** k + i) % 13) % 13])
        else:
            dp[k+1][(m + (10 ** k * int(S[-(k+1)])) % 13) % 13] += dp[k][m]
            # print('dp[k+1][(m + (10 ** k + int(S[-(k+1)])) % 13) % 13', dp[k+1][(m + (10 ** k + int(S[-(k+1)])) % 13) % 13])

        for i in range(13):
            dp[k+1][i] %= MOD
        # if S[k] == '?':
        #     for i in range(10):
        #         dp[k + 1][(m * 10 + i) % 13] += dp[k][m]
        # else:
        #     dp[k + 1][(m * 10 + int(S[k])) % 13] += dp[k][m]

        # for i in range(13):
        #     dp[k+1][i] %= MOD

print(dp[L][5])

### FIXED CODE ###

MOD = 10**9 + 7

S = input()
L = len(S)
memo = [[0 for i in range(14)] for j in range(L + 1)]
dp = [[0 for i in range(14)] for j in range(L + 1)]

dp[0][0] = 1

for k in range(L):
    for m in range(13):
        if S[k] == '?':
            for i in range(10):
                dp[k + 1][(m * 10 + i) % 13] += dp[k][m]
        else:
            dp[k + 1][(m * 10 + int(S[k])) % 13] += dp[k][m]

        for i in range(13):
            dp[k+1][i] %= MOD

print(dp[L][5])
### BUGGY CODE ###

def main():
    MOD = 10 ** 9 + 7
    S = input()
    u = [1] + [0] * 12
    v = [0] * 13
    m = 1
    shift = 0
    for s in reversed(S):
        if s == '?':
            for j in range(13):
                v[j] = sum(u[(j - (m * i) % 13) % 13] for i in range(10)) % MOD
            u, v = v, u
        else:
            shift = (shift + m * int(s)) % 13
        m = m * 10 % 13
    return u[(5 - shift) % 13]

print(main())


### FIXED CODE ###

def main():
    MOD = 10 ** 9 + 7
    S = input()
    u = [1] + [0] * 12
    v = [0] * 13
    m = 1
    shift = 0
    for s in reversed(S):
        if s == '?':
            for j in range(13):
                v[j] = sum(u[(j - (m * i) % 13) % 13] for i in range(10)) % MOD
            u, v = v, u
        else:
            shift = (shift + m * int(s)) % 13
        m = m * 10 % 13
    return u[(5 - shift) % 13]

print(main())
### BUGGY CODE ###

def sieve(n):
    a = range(n)
    a[0], a[1] = None, None
    for i in range(2, n):
        if i ** 2 >= n:
            break
        if a[i] is None:
            continue
        for j in range(i ** 2, n, i):
            a[j] = None
    j = 0
    for i in range(n):
        if a[i] is not None:
            a[j] = a[i]
            j += 1
    return a[0:j]

try:
    while True:
        print len(sieve(int(raw_input()) + 1))
except:
    pass

### FIXED CODE ###

import bisect


def sieve(n):
    a = range(n)
    a[0], a[1] = None, None
    for i in range(2, n):
        if i ** 2 >= n:
            break
        if a[i] is None:
            continue
        for j in range(i ** 2, n, i):
            a[j] = None
    j = 0
    for i in range(n):
        if a[i] is not None:
            a[j] = a[i]
            j += 1
    return a[0:j]

a = sieve(1000000)

try:
    while True:
        print bisect.bisect_right(a, int(raw_input()))
except:
    pass
### BUGGY CODE ###

import heapq;

n, u, v = [int(v) for v in input().split()]

vert = []

for i in range(n):
    vert.append([])

for i in range(n - 1):
    a, b = [int(v) - 1 for v in input().split()]
    vert[a].append(b)
    vert[b].append(a)

taka = u-1
aoki = v-1

q = []
heapq.heappush(q, (0, aoki))
aoki_dist = [-1] * n
closed = 0

while len(q) > 0:
    c0, i = heapq.heappop(q)
    aoki_dist[i] = c0
    closed |= (1 << i)

    c = c0 + 1
    for l in vert[i]:
        if closed & (1 << l) != 0:
            continue
        heapq.heappush(q, (c, l))

closed = 0
heapq.heappush(q, (0, taka))
max_dist = aoki_dist[taka] - 1

while len(q) > 0:
    c0, i = heapq.heappop(q)
    closed |= (1 << i)

    c = c0 + 1
    for l in vert[i]:
        if closed & (1 << l) != 0:
            continue
        closed |= (1 << l)
        if c >= aoki_dist[l]:
            continue
        if max_dist < aoki_dist[l] - 1:
            max_dist = aoki_dist[l] - 1
        heapq.heappush(q, (c, l))

print(max_dist)

### FIXED CODE ###

import heapq;

n, u, v = [int(v) for v in input().split()]

vert = []

for i in range(n):
    vert.append([])

for i in range(n - 1):
    a, b = [int(v) - 1 for v in input().split()]
    vert[a].append(b)
    vert[b].append(a)

taka = u-1
aoki = v-1

if taka == aoki:
    print(0)
    exit()

def bfs(begin):
    q = [(0, begin)]
    dist = [-1] * n
    dist[begin] = 0

    index = 0
    while index < len(q):
        c0, i = q[index]
        c = c0 + 1
        for l in vert[i]:
            if dist[l] >= 0:
                continue
            dist[l] = c
            q.append((c, l))
        index += 1
    return dist

aoki_dist = bfs(aoki)
taka_dist = bfs(taka)

ans = 0
for i in range(n):
    if taka_dist[i] < aoki_dist[i]:
        ans = max(ans, aoki_dist[i] - 1)

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

# 考えると、隣り合う列は結局 2*H 回ずることになり、
# それぞれの列間について最適な沈め順を見つけると、
# その順序関係を崩さないように全体の順番も構築できる（トポロジカルソートみたいに）ので、
# 各列間の最適解を求めて総和をとればいい

def accumulate(S1, S2):
    res = [0]
    c = 0
    for i in range(min(len(S1), len(S2))):
        if S1[i] == S2[i]:
            c += 1
        res.append(c)
    return res

import sys
input = sys.stdin.readline
inf = 10**8
H, W = map(int, input().split())
C = [input() for _ in range(H)]
C_T = list(zip(*C))[:-1]
C_T = ["".join(s) for s in C_T]
ans = 0
for C1, C2 in zip(C_T[:-1], C_T[1:]):
    # Z[i][j] := i 個ずれてて沈んでない方が j 個沈んでる状態の連結個数
    Z1 = []  # 左を押したとき（右が上にあるとき）
    Z2 = []  # 右を押したとき（左が上にあるとき）
    z1 = accumulate(C1, C2);  z1.reverse()
    Z1.append(z1)
    for j in range(1, H+1):
        z1 = accumulate(C1, C2[j:]);  z1.reverse();  Z1.append(z1)
        z2 = accumulate(C1[j:], C2);  z2.reverse();  Z2.append(z2)
    Z1 += Z2[::-1]
    # dp[i][j] := 左を i 個、右を j 個沈めるまでの最小コスト  # 逆かも（どっちでもいい）
    dp = [[inf] * (H+2) for _ in range(H+2)]
    dp[0][0] = 0
    for j in range(H+1):
        for k in range(H+1):
            cost = dp[j][k] + Z1[j-k][min(j, k)]
            dp[j+1][k] = min(dp[j+1][k], cost)
            dp[j][k+1] = min(dp[j][k+1], cost)
    ans += dp[H][H]
print(ans)


### FIXED CODE ###

# 考えると、隣り合う列は結局 2*H 回ずることになり、
# それぞれの列間について最適な沈め順を見つけると、
# その順序関係を崩さないように全体の順番も構築できる（トポロジカルソートみたいに）ので、
# 各列間の最適解を求めて総和をとればいい

def accumulate_reverse(S1, S2):
    n = min(len(S1), len(S2))
    res = [0] * (n+1)
    c = 0
    for i in range(n):
        if S1[i] == S2[i]:
            c += 1
        res[n-i-1] = c
    return res

inf = 10**8
H, W = map(int, input().split())
C = [input() for _ in range(H)]
C_T = list(zip(*C))
C_T = ["".join(s) for s in C_T]
ans = 0
for C1, C2 in zip(C_T[:-1], C_T[1:]):
    # Z[i][j] := i 個ずれてて沈んでない方が j 個沈んでる状態の連結個数
    Z1 = []  # 左を押したとき（右が上にあるとき）
    Z2 = []  # 右を押したとき（左が上にあるとき）
    Z1.append(accumulate_reverse(C1, C2))
    for j in range(1, H+1):
        Z1.append(accumulate_reverse(C1, C2[j:]))
        Z2.append(accumulate_reverse(C1[j:], C2))
    Z1 += Z2[::-1]
    # dp[i][j] := 左を i 個、右を j 個沈めるまでの最小コスト  # 逆かも（どっちでもいい）
    dp = [[inf] * (H+2) for _ in range(H+2)]
    dp[0][0] = 0
    for j in range(H+1):
        for k in range(H+1):
            cost = dp[j][k] + Z1[j-k][min(j, k)]
            dp[j+1][k] = min(dp[j+1][k], cost)
            dp[j][k+1] = min(dp[j][k+1], cost)
    ans += dp[H][H]
print(ans)
### BUGGY CODE ###

def resolve():
    N = int(input())
    P = list(map(int, input().split()))

    n = 0
    x = 10 ** 20
    for i in range(N):
      if x < P[i]:
        continue
      else:
        x = P[i]
        for j in range(i):
            if P[i] > P[j]:
                break
        else:
            n += 1
    print(n)

resolve()

### FIXED CODE ###

def resolve():
    N = int(input())
    P = list(map(int, input().split()))

    n = 0
    x = 10 ** 20
    for i in range(N):
        if x >= P[i]:
            x = P[i]
            n += 1
    print(n)

resolve()
### BUGGY CODE ###


def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n = readInt()
data = [readInts() for i in range(n)]
xy = {}
for x,y in data:
	if x in xy:
		xy[x].append(y)
	else:
		xy[x] = [y]
for x in xy:
	xy[x].sort()

#print(xy)
ans = 0
for x1,y1 in data:
	for x2 in xy:
		ans = max(ans, abs(x1-x2)+abs(y1-xy[x2][0]),abs(x1-x2)+abs(y1-xy[x2][-1]))

print(ans)

### FIXED CODE ###

from collections import defaultdict
from collections import deque
from collections import Counter
import math
import itertools

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n = readInt()
data = []
for i in range(n):
	x,y = readInts()
	data.append([x+y,x,y,x-y])
ans = 0
data.sort(key=lambda x:x[0])
ans = max(ans,abs(data[-1][1]-data[0][1])+abs(data[-1][2]-data[0][2]))
data.sort(key=lambda x:x[1])
ans = max(ans,abs(data[-1][1]-data[0][1])+abs(data[-1][2]-data[0][2]))
data.sort(key=lambda x:x[2])
ans = max(ans,abs(data[-1][1]-data[0][1])+abs(data[-1][2]-data[0][2]))
data.sort(key=lambda x:x[3])
ans = max(ans,abs(data[-1][1]-data[0][1])+abs(data[-1][2]-data[0][2]))
print(ans)