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

import sys
from collections import defaultdict
from functools import lru_cache

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

MOD = 10**9 + 7
P = 2 ** 127 - 1

N = int(readline())
m = map(int, read().split())
A, B = zip(*zip(m, m))

pow2 = [1] * (N + 10)
for n in range(1, N + 10):
    pow2[n] = pow2[n - 1] * 2 % MOD

@lru_cache(None)
def inv_mod(a):
    b = P
    u, v = 1, 0
    while a:
        t = b // a
        a, b = b - t * a, a
        u, v = v - t * u, u
    if b < 0:
        v = -v
    return v % P

def to_key(a, b):
    if a == 0:
        return -1
    x = inv_mod(a) * b % P
    return x

def pair_key(key):
    if key == -1:
        return 0
    if key == 0:
        return -1
    return P - inv_mod(key)
  
counter = defaultdict(int)
origin = 0
for a, b in zip(A, B):
    if a == b == 0:
        origin += 1
        continue
    key = to_key(a, b)
    counter[key] += 1

answer = origin
k = 1
for key, cnt in counter.items():
    key1 = pair_key(key)
    if key1 not in counter:
        k *= pow(2, cnt, MOD)
    elif key < key1:
        x, y = cnt, counter[key1]
        k *= pow(2, x, MOD) + pow(2, y, MOD) - 1
    k %= MOD
answer += k - 1
answer %= MOD
print(answer)


### FIXED CODE ###

import sys
from collections import defaultdict
from math import gcd

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

MOD = 10**9 + 7

N = int(readline())
m = map(int, read().split())
A, B = zip(*zip(m, m))

pow2 = [1] * (N + 10)
for n in range(1, N + 10):
    pow2[n] = pow2[n - 1] * 2 % MOD

def to_standard_form(a, b):
    if a == 0:
        return (0, 1)
    g = gcd(a, b)
    a //= g
    b //= g
    if a < 0:
        return (-a, -b)
    return (a, b)

counter0 = defaultdict(int)
counter1 = defaultdict(int)
origin = 0
for a, b in zip(A, B):
    if a == b == 0:
        origin += 1
        continue
    a, b = to_standard_form(a, b)
    if b <= 0:
        counter0[(a, b)] += 1
    else:
        counter1[(b, -a)] += 1
        counter0[(b, -a)] += 0

answer = origin
k = 1
for key, cnt0 in counter0.items():
    cnt1 = counter1[key]
    x = pow2[cnt0] + pow2[cnt1]
    k = k * (x - 1) % MOD

answer += k - 1
answer %= MOD
print(answer)
### BUGGY CODE ###

import bisect
import sys
readline = sys.stdin.readline
N = int(readline())
ls = sorted(list(map(int, readline().split())))
#ls *= 100
#N *= 100
#print(N, ls)
#print(len(ls))

ans = 0
for i in range(N-2):
  a = ls[i]
  for j in range(i+1, N-1):
    b = ls[j]
    #pos = bisect.bisect_left(ls, a+b)
    #ans += pos - j - 1
    pos = bisect.bisect_left(ls, a+b, lo=j)
    ans += pos - j - 1
print(ans)


### FIXED CODE ###

import bisect
import sys
input = sys.stdin.readline
N = int(input())
ls = list(map(int, input().split()))
ls.sort()

ans = 0
for i in range(N-2):
  a = ls[i]
  for j in range(i+1, N-1):
    b = ls[j]
    pos = bisect.bisect_left(ls, a+b)
    ans += pos - j - 1
print(ans)
### BUGGY CODE ###

A,B,C,D=map(int,input().split())
n=0
for i in range(B-A+1):
    if (A+i)%C != 0 and (A+i)%D != 0:
        n=n+1
print(n)

### FIXED CODE ###

def euclid(a,b):
	c=0
	if (a-b)<0:
		c=a
		a=b
		b=c
	r=-1
	while r!=0:
		r=a%b
		a=b
		b=r
	return a

A,B,C,D=map(int,input().split())
c1=(A-1)//C
d1=(A-1)//D
c2=B//C
d2=B//D
k=euclid(C,D)
CD=C*D//k
cd1=(A-1)//CD
cd2=B//CD
c3=c2-c1
d3=d2-d1
cd3=cd2-cd1
print(B-A+1-c3-d3+cd3)
### BUGGY CODE ###

S = input()
Q = int(input())
reverse_flg = False
for q in range(Q):
  r = input().split()
  if len(r) == 1:
    reverse_flg = not reverse_flg
  else:
    if int(r[1]) == 1:
      S = r[2] + S if not reverse_flg else S + r[2]
    else:
      S = S + r[2] if not reverse_flg else r[2] + S

if reverse_flg:
  S = S[::-1]

print(S)

### FIXED CODE ###

S = input()
Q = int(input())
reverse_flg = False

b_str = ""
f_str = ""

for q in range(Q):
  r = input().split()
  if len(r) == 1:
    reverse_flg = not reverse_flg
  else:
    # Sは最終的に加えればいいので、それを最適化する
    if int(r[1]) == 1:
      if reverse_flg:
        f_str = f_str + r[2]
      else:
        b_str = r[2] + b_str
    else:
      if reverse_flg:
        b_str = r[2] + b_str
      else:
        f_str = f_str + r[2]

S = b_str + S + f_str

if reverse_flg:
  S = S[::-1]

print(S)
### BUGGY CODE ###

import io
import os

input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

R, C, K = [int(x) for x in input().split()]
grid = [[0 for c in range(C)] for r in range(R)]
for r, c, v in ((int(x) for x in input().split()) for i in range(K)):
    grid[r - 1][c - 1] = v


dp = [[[0 for i in range(3 + 1 + 1)] for c in range(C + 1)] for r in range(R + 1)]
dp2 = [[0 for c in range(C + 1)] for r in range(R + 1)]

inf = float("inf")
for r in range(R + 1):
    for c in range(C + 1):
        dp[r][c][-1] = -inf
for r in range(R):
    for c in range(C):
        for numTakenThisRow in range(3 + 1):
            best = max(
                dp[r][c - 1][numTakenThisRow],  # came from left
                dp2[r - 1][c],  # came from top, didn't take curr
                dp[r][c - 1][numTakenThisRow - 1]
                + grid[r][c],  # came from left, took curr
                dp2[r - 1][c] + grid[r][c]
                if numTakenThisRow == 1
                else 0,  # came from top, took curr
            )
            dp[r][c][numTakenThisRow] = best
        dp2[r][c] = max(dp[r][c][i] for i in range(3 + 1))
print(dp2[R - 1][C - 1])


### FIXED CODE ###

import io
import os
from collections import defaultdict

DEBUG = False
if not DEBUG:

    input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

    R, C, K = [int(x) for x in input().split()]
    grid = [[0 for c in range(C)] for r in range(R)]
    for r, c, v in ((int(x) for x in input().split()) for i in range(K)):
        grid[r - 1][c - 1] = v
else:
    import random

    random.seed(0)
    R, C = 3000, 3000
    # 2 * 10**5 / 90 * 10**5 full
    grid = [
        [int(random.randint(1, 90) <= 2) * random.randint(0, 10 ** 9) for c in range(C)]
        for r in range(R)
    ]
    print(sum(bool(grid[r][c]) for r in range(R) for c in range(C)))
    print("done gen")

    from timeit import default_timer as timer

    startTime = timer()


currRow = [[0 for i in range(3 + 1)] for c in range(C + 1)]
prevRow = [0 for c in range(C + 1)]
nextPrevRow = [0 for c in range(C + 1)]

inf = float("inf")
for r in range(R):
    for c in range(C):
        for numTakenThisRow in range(3 + 1):
            best = max(
                currRow[c - 1][numTakenThisRow],  # came from left
                prevRow[c],  # came from top, didn't take curr
                currRow[c - 1][numTakenThisRow - 1] + grid[r][c]
                if numTakenThisRow
                else 0,  # came from left, took curr
                prevRow[c] + grid[r][c]
                if numTakenThisRow == 1
                else 0,  # came from top, took curr
            )
            currRow[c][numTakenThisRow] = best
        nextPrevRow[c] = max(currRow[c][i] for i in range(3 + 1))
    prevRow, nextPrevRow = nextPrevRow, prevRow
print(prevRow[C - 1])

if DEBUG:
    print(timer() - startTime)
### BUGGY CODE ###

def main():
    N,K = list(map(int,input().split()))
    H = list(map(int,input().split()))

    for _ in range(K):
        if(len(H) > 0):
            maximum = max(H)
            H.remove(maximum)

    print(sum(H))

if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    N,K = list(map(int,input().split()))
    H = list(map(int,input().split()))

    sorted_H = sorted(H,reverse=True)

    for i in range(K):
        if(i < len(sorted_H)):
            sorted_H[i] = 0

    '''
    for _ in range(K):
        if(len(H) > 0):
            maximum = max(H)
            H.remove(maximum)
            '''

    print(sum(sorted_H))

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

def l(): return list(map(int, input().split()))
def m(): return map(int, input().split())

def sieve(n): # エラトステネスの篩ですよ
  num = [True]*n
  num[0] = num[1] = False
  for i in range(2,int(n**0.5)+1):
    if num[i]:
      for j in range(i**2, n, i):
        num[j] = False
  return [i for i in range(2,n) if num[i]]

def main():
  q = int(input())
  for i in range(q):
    l, r = m()
    prime = sieve(r+1)
    # print(prime)
    likp = [0]*r
    for i in prime:
      if (i+1) // 2 in prime:
        likp[i-1] = 1
    # print(likp)
    sm = [0]*(r+1)
    for i in range(r):
      sm[i+1] = sm[i] + likp[i]
    # print(sm)
    print(sm[r] - sm[l-1])
   


if __name__ == '__main__':
  main()

### FIXED CODE ###

q = int(input())
l, r = [0]*q, [0]*q
for i in range(q):
    l[i], r[i] = map(int, input().split())

MAX = 101010
is_prime = [1]*MAX
is_prime[0] = 0
is_prime[1] = 0
for i in range(2,MAX):
    if not is_prime[i]: 
        continue
    for j in range(i*2, MAX, i):
        is_prime[j] = 0

a = [0]*MAX
for i in range(MAX):  # ,,2
    if i%2 == 0: 
        continue
    if is_prime[i] and is_prime[(i+1)//2]: 
        a[i] = 1

s = [0]*(MAX+1)
for i in range(MAX): 
    s[i+1] = s[i] + a[i]

for i in range(q):
    print(s[r[i]+1]-s[l[i]])
### BUGGY CODE ###

a,b,c,n=map(int,input().split())
q=0
for i in range(n//a+1):
  for j in range((n-a*i)//b+1):
    if(n-i*a-j*b)%c==0and (n-i*a-j*b)//c>=0:
      q+=1
print(q)

### FIXED CODE ###

a,b,c,n=map(int,input().split())
q=0
for i in range(n//a+1):
  for j in range((n-a*i)//b+1):
    t=n-i*a-j*b
    if t%c==0:
      q+=1
print(q)
### BUGGY CODE ###

import heapq
N, M = [int(x) for x in input().split()]
AB_list = sorted([input().split() for _ in range(N)], key=lambda x: int(x[0]))
h = []
ans = 0
for i in range(1, M+1):
    lst = AB_list[:]
    for A, B in lst:
        if (int(A) <= i):
            tmp = AB_list.pop(0)
            heapq.heappush(h, -1 * int(tmp[1]))
        else: break
    # print(AB_list, h)
    if (len(h)):
        ans += -1 * heapq.heappop(h)
print(ans)


### FIXED CODE ###

import heapq
N, M = [int(x) for x in input().split()]
AB_list = [[] for _ in range(M)]
for _ in range(N):
    A, B = list(map(int, input().split()))
    if (A > M): continue
    AB_list[A-1].append(B)
h = []
ans = 0
for i in range(M):
    for B in AB_list[i]:
        heapq.heappush(h, -B)
    # print(AB_list, h)
    if (len(h)):
        ans += -heapq.heappop(h)
print(ans)
### BUGGY CODE ###

a,b,k = map(int,input().split())
lis = [i for i in range(a,b+1)]

ans = lis[:k]+ lis[-k:]

if len(lis)<k*2:
  for i in lis:
    print(i)
else:
  for i in ans:
    print(i)


### FIXED CODE ###

a,b,k = map(int,input().split())

if (b-a)<k*2:
  for i in range(a,b+1):
    print(i)
else:
  for i in range(a,a+k):
    print(i)
  for j in range(b-k+1,b+1):
    print(j)
### BUGGY CODE ###

A, B, Q = map(int, input().split())
ls = list(int(input()) for i in range(A))
lt = list(int(input()) for i in range(B))
lx = list(int(input()) for i in range(Q))

def go(x, list, N):
  clist = []
  for i in range(N):
    clist.append(abs(list[i] - x))
  return min(clist)

for x in lx:
  l = []
  for i in range(A):
    if x - ls[i] < 0:
      break
  if i:
    l.append(abs(ls[i-1]-x) + go(ls[i-1], lt, B))
  if i < A:
    l.append(abs(ls[i]-x) + go(ls[i], lt, B))
  for i in range(B):
    if x - lt[i] < 0:
      break
  if i:
    l.append(abs(x-lt[i-1]) + go(lt[i-1], ls, A))
  if i < B:
    l.append(abs(lt[i]-x) + go(lt[i], ls, A))
  print(min(l))

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

def heap_localsort(Array, i):
    lsub, rsub = 2*i+1, 2*i+2
    maxIndex = i
    if lsub <= len(Array)-1 and Array[lsub] > Array[maxIndex]:
        maxIndex = lsub
    if rsub <= len(Array)-1 and Array[rsub] > Array[maxIndex]:
        maxIndex = rsub
    Array[i], Array[maxIndex] = Array[maxIndex], Array[i]
    return(Array)

def heap_sort(Array):
    for i in reversed(range(int(len(Array)/2))):
        heap_localsort(Array, i)
    return(Array)

def heap_push(Array, addElem):
    Array.append(addElem)
    return(heap_sort(Array))

def heap_pop(Array):
    init = A[0]
    Array[0], Array[len(Array)-1] = Array[len(Array)-1], Array[0]
    Array.pop(len(Array)-1)
    heap_sort(A)
    return(init)
 
def function(A, M):
    heap_sort(A)
    for i in range(M):
        max = heap_pop(A)
        heap_push(A, int(max / 2))
    return sum(A)

N = list(map(int, (input().split(' '))))
A = list(map(int, (input().split(' '))))
print(function(A, N[1]))

### FIXED CODE ###

import heapq

N = list(map(int, (input().split(' '))))
A = list(map(lambda x: x*(-1), map(int, (input().split(' ')))))

heapq.heapify(A)
for i in range(N[1]):
    heapq.heappush(A, int(heapq.heappop(A) / 2))

print(-sum(A))
### BUGGY CODE ###

s=0
for i in range(1,int(input())):
    s+=i
print(s)

### FIXED CODE ###

s=0
for i in range(1,int(input())):
    s+=i
print(s)
### BUGGY CODE ###

s = list(input())
q = int(input())
rv = False
for i in range(q):
    t = input().split(' ')
    if t[0] == '1':
        rv = True if not rv else False
    else:
        if t[1] == '1' and not rv or t[1] == '2' and rv:
            s.insert(0, t[2])
        else:
            if t[1] == '1' and rv or t[1] == '2' and not rv:
                s.append(t[2])
print(''.join(s) if not rv else ''.join(s[::-1]))

### FIXED CODE ###

from collections import deque
s = list(input())
q = int(input())
rv = False
fr = deque()
re = []
for i in range(q):
    t = input().split(' ')
    if t[0] == '1':
        rv = True if not rv else False
    else:
        if t[1] == '1' and not rv or t[1] == '2' and rv:
            fr.appendleft(t[2])
        else:
            if t[1] == '1' and rv or t[1] == '2' and not rv:
                re.append(t[2])
if rv:
    re.reverse()
    s.reverse()
    fr.reverse()
    print(''.join(re + s) + ''.join(fr))
else:
    print(''.join(fr) + ''.join(s + re))
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
l = [0 for _ in range(max(a)+1)]
for i in range(n):
  if l[a[i]] == 0:
    l[a[i]] += 1
  else:
    print('NO')
    break
else:
  print('YES')

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
if len(a) != len(set(a)):
  print('NO')
else:
  print('YES')
### BUGGY CODE ###

box = []
for mak in range(int(input())) :
    com = input().split()
    if   com[0] == 'insert'      : box.insert(0, com[1])
    elif com[0] == 'deleteFirst' : del box[0]
    elif com[0] == 'deleteLast'  : del box[-1]
    else : 
        if com[1] in box :
            box.remove(com[1])
print(' '.join(box))

### FIXED CODE ###

from collections import deque
dq = deque()
for mak in range(int(input())) :
    com = input().split()
    if   com[0] == 'insert'      : dq.appendleft(com[1])
    elif com[0] == 'deleteFirst' : dq.popleft()
    elif com[0] == 'deleteLast'  : dq.pop()
    else : 
        if com[1] in dq :
            dq.remove(com[1])
print(' '.join(dq))
### BUGGY CODE ###



def main(N,A):
    B=[0]

    for i in range(int(len(A))):
        T = A[i] + B[i]
        B.append(T)
    count = 0
    for i in range(int(len(B))):
        for m in range(i+1):
            if i > i-m:
                T = B[i]-B[i-m]
                # print(i, m)
                # print(B[i],B[i-m])
                # print(T)
                if T == 0:
                    # print("kore",B[i],B[i-m])
                    count += 1

    #print(count)
    #print(B)
    return print(count)




if __name__ == "__main__":
    N=int(input())
    A=list(map(int,input().split()))
    main(N,A)

### FIXED CODE ###

import collections

def main(N,A):
    B=[0]
    count = 0
    for i in range(N):
        T = A[i] + B[i]

        B.append(T)
    c = collections.Counter(B)

    for i in range(len(c)):
        k, v = c.popitem()
        for z in range(v):
            count += z

    return print(count)

if __name__ == "__main__":
    N=int(input())
    A=list(map(int,input().split()))

    main(N,A)
### BUGGY CODE ###

#coding=UTF-8

mozir=input()
hyo=mozir.split(' ')
N=int(hyo[0])
M=int(hyo[1])

a=[]
b=[]
for idx in range(0,M,1):
    mozir=input()
    hyo=mozir.split(' ')
    a.append(int(hyo[0]))
    b.append(int(hyo[1]))

# collect x s.t. exists (1,x)
myon=[]
# and collct y s.t. exists (y,N)
meguru=[]
for idx in range(0,M,1):
    if a[idx]==1:
        myon.append(b[idx])

    if b[idx]==N:
        meguru.append(a[idx])

ans=False
for youmu in myon:
    if youmu in meguru:
        ans=True
        break

prefix='' if ans else 'IM'
print(prefix+'POSSIBLE')


### FIXED CODE ###

#coding=UTF-8

#メモリ大富豪プレイ
mozir=input()
hyo=mozir.split(' ')
N=int(hyo[0])
M=int(hyo[1])

a=[]
b=[]
for idx in range(0,M,1):
    mozir=input()
    hyo=mozir.split(' ')
    a.append(int(hyo[0])-1)
    b.append(int(hyo[1])-1)

# collect x s.t. exists (1,x)
myon_tbl=[False]*N
# and collct y s.t. exists (y,N)
meguru_tbl=[False]*N
for idx in range(0,M,1):
    if a[idx]==0:
        myon_tbl[b[idx]]=True

    if b[idx]==N-1:
        meguru_tbl[a[idx]]=True

ans=False
for idx in range(0,N,1):
    if myon_tbl[idx] and meguru_tbl[idx]:
        ans=True
        break

prefix='' if ans else 'IM'
print(prefix+'POSSIBLE')
### BUGGY CODE ###

import sys
sys.setrecursionlimit(5000)

N = int(input())
A = [(int(a), i) for i, a in enumerate(input().split())]
A = sorted(A, reverse=True)

memo = {}

def solve(i, l, r):
    if i==N: return 0

    key = (i,l,r)
    if key in memo: return memo[key]
    
    a, loc = A[i]
    score_l = a*abs(l-loc) + solve(i+1, l+1, r)
    score_r = a*abs(r-loc) + solve(i+1, l, r-1)
    retval = max(score_l, score_r)
    memo[key]=retval
    
    return retval
    
print(solve(0, 0, N-1))

### FIXED CODE ###

import sys
sys.setrecursionlimit(5000)

N = int(input())
A = [(int(a), i) for i, a in enumerate(input().split())]
A = sorted(A, reverse=True)

memo = {}

def solve(i, l, r):
    if i==N: return 0

    key = l*N+r
    if key in memo: return memo[key]
    
    a, loc = A[i]
    score_l = a*abs(l-loc) + solve(i+1, l+1, r)
    score_r = a*abs(r-loc) + solve(i+1, l, r-1)
    retval = max(score_l, score_r)
    memo[key]=retval
    
    return retval
    
print(solve(0, 0, N-1))
### BUGGY CODE ###

from itertools import combinations
import numpy as np

n, k = map(int, input().split())
sl = [[int(i) for i in input().split()] for _ in range(n)]

sa = np.array(list(combinations(sl, k)))
c = sa.shape[0]
y = np.sum(sa[:,:,1], axis=1).reshape(c)
k = np.power(np.array([np.unique(l).shape[0] for l in sa[:,:,0]]), 2)
print(np.max(y + k))

### FIXED CODE ###

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

top = [0]*n # t毎に最高のdを格納するlist
sub = [] # それ以外のdを格納するlist
cst = [0] # cumsum top
css = [0] # cumsum sub

for _ in range(n):
    t, d = (int(i) for i in input().split())
    t -= 1
    if top[t] == 0:
        top[t] = d
    elif d > top[t]:
        sub.append(top[t])
        top[t] = d
    else:
        sub.append(d)

top.sort(reverse=True)
sub.sort(reverse=True)

for i in range(n): # カテゴリ内最大のdが高い順に累積
    if top[i] != 0:
        cst.append(cst[-1] + top[i])

for i in range(len(sub)): # それ以外の全てのカテゴリの寿司のdが高い順に累積
    css.append(css[-1] + sub[i])

po = 0
for i in range(1, k+1):
    if len(cst)-1 >= i and len(css)-1 >= k-i:
        po = max(cst[i] + css[k-i] + i*i, po)

print(po)
### BUGGY CODE ###

import collections

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

dic = collections.defaultdict(lambda:[])
pairs = []

for _ in range(M):
  P, Y = map(int, input().split())
  pairs.append((P, Y))
  dic[P].append(Y)

for key in dic:
  dic[key].sort()
  dic[key] = {v:i+1 for i,v in enumerate(dic[key])}

while pairs:
  P, Y = pairs.pop(0)
  print(str(P).zfill(6) + str(dic[P][Y]).zfill(6))

### FIXED CODE ###

from bisect import bisect_right

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

Ps, Ys, vals = [], [], {}
for i in range(M):
  P, Y = map(int, input().split())
  Ps.append(P)
  Ys.append(Y)

  if P not in vals:
    vals[P] = []
  vals[P].append(Y)

for P in vals:
  vals[P].sort()

for i in range(M):
  pref = str(Ps[i]).zfill(6)
  city = str(bisect_right(vals[Ps[i]], Ys[i])).zfill(6)
  print(pref + city)
### BUGGY CODE ###

n = int(input())

P = [int(_) for _ in input().split()]


cnt=0
for i in range(n):
    if min(P[:i+1])==P[i]:
        cnt+=1
print(cnt)

### FIXED CODE ###

n = int(input())

P = [int(_) for _ in input().split()]

cnt=0
a = P[0]
for i in range(n):
    a = min(a,P[i])
    if P[i] <= min(a,P[i]):
        cnt+=1
print(cnt)
### BUGGY CODE ###

n = int(input())
s = input()

r, g, b = [0] * n, [0] * n, [0] * n
for i in range(0, n):
    if i == 0:
        if s[i] == 'R':
            r[i] = 1
        elif s[i] == 'G':
            g[i] = 1        
        elif s[i] == 'B':
            b[i] = 1
    else:
        if s[i] == 'R':
            r[i] = r[i-1] + 1
            g[i] = g[i-1]
            b[i] = b[i-1]
        elif s[i] == 'G':
            r[i] = r[i-1]
            g[i] = g[i-1] + 1
            b[i] = b[i-1]
        elif s[i] == 'B':
            r[i] = r[i-1]
            g[i] = g[i-1]
            b[i] = b[i-1] + 1   

cnt = 0
for i in range(0, n-2):
    for j in range(n-1, i+1, -1):
        if s[i] != s[j]:
            if s[i] != 'B' and s[j] != 'B':
                cnt += b[j] - b[i]
                if (i+j) % 2 == 0 and s[(i+j)//2] == 'B':
                    cnt -= 1
            elif s[i] != 'G' and s[j] != 'G':
                cnt += g[j] - g[i]
                if (i+j) % 2 == 0 and s[(i+j)//2] == 'G':
                    cnt -= 1
            elif s[i] != 'R' and s[j] != 'R':
                cnt += r[j] - r[i]
                if (i+j) % 2 == 0 and s[(i+j)//2] == 'R':
                    cnt -= 1
print(cnt)

### FIXED CODE ###

def main():
    n=int(input())
    s=input()
    r=[]
    g=[]
    b=[]
    rdict={}
    gdict={}
    bdict={}
    ans=0
    for i in range(n):
        if s[i]=='R':
            r.append(i)
            rdict[2*i]=2*i
        if s[i]=='G':
            g.append(i)
            gdict[2*i]=2*i
        if s[i]=='B':
            b.append(i)
            bdict[2*i]=2*i
    ans=len(r)*len(g)*len(b)
    for i in r:
        for j in g:
            if i+j in bdict:
                ans-=1
    for i in g:
        for j in b:
            if i+j in rdict:
                ans-=1
    for i in b:
        for j in r:
            if i+j in gdict:
                ans-=1
    print(ans)
    
if __name__ == '__main__':
    main()
### BUGGY CODE ###

import numpy as np

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

k = np.zeros(n,dtype='int')

for i in range(m):
    l,r = map(int,input().split())
    k[l-1:r] += 1
print(len(k[k==m]))

### FIXED CODE ###

import numpy as np

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

L = 1
R = n

for i in range(m):
    l,r = map(int,input().split())
    L = max(L,l)
    R = min(r,R)
print(max(0,R-L+1))
### BUGGY CODE ###

n = int(input().strip())
L = list(map(int, input().strip().split()))
ans=1
for v in L:
    ans*=v

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

### FIXED CODE ###

n = int(input().strip())
L = list(map(int, input().strip().split()))
L.sort(reverse=True)
if L[-1]==0:
    print(0)
    exit()
ans=1
for v in L:
    ans*=v
    if ans>10**18:
        print(-1)
        exit()

print(ans)