peterverebics/CodeNet_Python_118 huggingface dataset:
n, k = map(int, input().split())
teki_list = [i for i in map(int, input().split())]

#敵を弱い順に並べる
teki_list.sort()
#強いやつに必殺技を使う
if k <= len(teki_list) and k != 0:
    del teki_list[-k:]
else:
    del teki_list[:]

print(sum(teki_list))
data = input().split()
 
n = int(data[0])
k = int(data[1])

hpstr = input().split()
hp = []

for i in range(n):
  hp.append(int(hpstr[i]))

hp.sort()

print(hp)

ans = 0
for i in range(n - k):
  ans += hp[i]
 
print(ans)
n, k = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
if k >= n:
    print(0)
else:
    h.sort()
    ans = 0
    for i in h[: - k]:
        ans += i
    print(ans)
n, k=map(int, input().split())
h=list(map(int, input().split()))
n-=k
h.sort
hp=0
for i in range(n):
  hp+=h[i]
print(hp)
n,k=map(int,input().split())
h=input().split()
s=0
g=sorted(h,reverse=True)
t=0
i=0
if k>=n:
    print(0)
else:
    for i in g:
        t+=1
        if t<=k:
            continue
        else:
            i=int(i)
            s+=i
    print(s)
n,k = map(int,input().split())

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

h.sort(reverse=True)
ans = 0

if k == 0 :
    ans = sum(h)
elif k <= n :
    for i in range(k):
        h[i] = 0
    print(sum(h))
else :
    print(0)
N, K = map(int, input().split())
H = sorted(list(map(int, input().split())))
if len(H) <= K:
    print('0')
elif K == 0:
    print(sum(H))
else:
    print(sum(H[:K+1]))
import math

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

enemys.sort(reverse=True)
count = 0
for e in enemys:
  if(k > 0):
    count += 1
    k -= 1
  else:
    count += e

print(count)
N,K = map(int,input().split())
H = list(map(int,input().split()))

sort = sorted(H, reverse = True)
print(sort)

ans = 0
for i in range(N):
    if i+1 > K:
        ans += sort[i]
    
print(ans)
n,k = map(int,input().split())
h= list(map(int,input().split()))
sorted(h)
if n <=k:
    print(0)
else:
    print(sum(h[:n-k]))
# -*- coding: utf-8 -*-
n,k=map(int, input().split())
h=list(map(int, input().split()))
b =sorted(h)[0:-n]

#攻撃回数
print(sum(b))
N, K = input().split()
N = int(N)
K = int(K)
H = input()
H = [int(i) for i in H.split()]
H.sort()
while (K > 0 and len(H) == 0):
  del H[-1]
  K -=1
print(sum(H))
N,K=map(int,input().split())
L=list(map(int,input().split()))
sum(L[:K])
N,K=map(int,input().split())
H= list(map(int,input().split()))

y=sorted(H)
y.sort(reverse=True)
x=0
print(x)
for i in range (K,N):
    x=x+y[i]
    
print(x)
N, K = [int(i) for i in input().split()]
H = sorted([int(i) for i in input().split()])

if K < N and  K != 0:
    print(sum(H[: -K]))
else:
    print(sum(H))
N,K = input().split()
H = list(input().split())
N = int(N)
K = int(K)
H = [int(h) for h in H]
H.sort()
print(sum(H[0:N - K]))
#!/usr/bin/env python3
n,k = map(int,input().split())
h = list(map(int,input().split()))
if n > k:
    print(sum(h[:n-k])) 
else: print(0)
N,K=map(int,input().split())
H=list(map(int,input().split()))

H.sort()

if K>=N:
    print(0)
else:
    print(sum(H[:-K]))
n,k=map(int,input().split())
h=map(int,input().split())
h=sorted(h)
if n<=k:
  print('0')
  exit()
for i in range(k):
  h[i-1]=0
print(sum(h))
N, K = map(int, input().split())
H = [int(h) for h in input().split()]
H = list(sorted(H, reverse = True))
print(H)
if len(H) <= K:
  print(0)
else:
  del H[0:K]
  print(sum(H))
n,k=map(int,input().split())
s=list(map(int,input().split()))

if n<=k:
  print(0)
else:
  s.sort()
  print(sum(s[:-k]))
n,k=map(int,input().split())
hi=[]
for i in map(int,input().split()):
    hi.append(i)
hi.sort
hsum=0
for i in range(n-k):
    hsum=hsum+hi[i]
print(hsum)
n, k = map(int, input().split())
h = list(map(int, input().split()))
sorted(h)
ans = 0
if len(h) == n:
    for i in range(k):
        try:
            h.pop()
        except:
            pass
    for x in h:
        ans += x
    print(ans)
n, k = [int(x) for x in input().split()]

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

if n < k:
    print("0")

s_n = sorted(h_n)

print(sum(s_n[:n - k]))
n, k = list(map(int, input().split()))
h = list(map(int, input().split()))
h.sort()
print(sum(h[0:len(h)-k]))
n,k = map(int,input().split())
a = list(map(int,input().split()))

a.sort()

print(sum(a[:-k]))
# coding: utf-8
h,k = map(int, input().split())
H = sorted(map(int, input().split()))

print(sum(H[:-k]))
# coding utf-8
import math
import sys


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

H = list(map(int, input().rstrip().split()))
H.sort()

if N > K:
    ans = sum(H[:-K])
else:
    ans = 0

print(ans)
N,K=map(int,input().split())
H=list(map(int,input().split()))
ans=0
H.sort()
for i in range(N):
    if i>=N-K:
        ans+=1
    else:
        ans+=H[i]
print(ans)
enemmyCountN,killerTimeK = map(int,input().split())
enemyHp = input().split()

enemyHp.sort()

resultEnemyCount = enemmyCountN - killerTimeK
countNormal = 0

if killerTimeK >= enemmyCountN:
    print('0')

else:
    for i in range(resultEnemyCount):
        countNormal += int(enemyHp[i])
    print(countNormal)
h,n=[int(x) for x in input().split()]
a=list(map(int,input().split()))
sorted(a)
a=a[-n:]
print(sum(a))
#153 Fennec vs Monster
n,k = map(int,input().split())
tairyoku = list(map(int,input().split()))
tairyoku.sort(reverse=True)

if k == 0:
    print(sum(tairyoku))
    
else:
    del tairyoku[:k]
    print(tairyoku)
    print(sum(tairyoku))
n,k,*h=map(int,open(0).read().split());h.sort();print(sum(h[:-k]))
def main():
    n, k = [int(i) for i in input().split()]
    num = [int(i) for  i in input().split()]
    if k >= n:
        return 0
    else:
        num = sorted(num)
        return sum(num[:-k])
print(main())
#!/usr/bin/python
# -*- coding: UTF-8 -*-
n,k = input().split()
k = int(k)
n =int(n)

healths = input().split()
res = 0

healths.sort()
for i in range(n):
    if i >= n-k:
        break
    res = res + int(healths[i])

print(res)
a = list(map(int,input().split()))
b = list(map(int,input().split()))

if len(b) <= a[1]:
    print("0")
elif a[1]==0:
    print(sum(b))
else:
    del b[a[0]-1]
    b.sort(reverse=True)
    print(sum(b[(a[1]-1):len(b)]))
    print(b[a[1]:])
#C
NK = input().split(' ')
N = int(NK[0])
K = int(NK[1])
Hi = input().split(' ')
if K >= N:
    print(0)
else:
    Hi.sort()
    for s in range(K):
        Hi.pop(N - 1 - s)
    count = 0
    for j in range(N-K):
        count += int(Hi[j])
    print(count)
import math
n,k=map(int,input().split())
l=list(map(int,input().split()))
l.sort()
ans=0
if k>=n:
    ans=n
else:
    list_new=l[0:n-k]
    ans=sum(list_new)
print(ans)
N,K= map(int,(input().split()))
H=list(map(int,(input().split())))
atk=0
H.sort()
del H[-K:]
atk=sum(H)
print(atk)
N, K = map(int,input().split())
H = list(map(int,input().split()))
H.sort()
cnt = max(N,K)
ans = 0
for i in range(N-cnt):
    ans+=H[i]
print(ans)
n, k = map(int, input().split())
h = sorted(map(int, input().split()))

print(sum(h[-k:]) if k!=1 else k)
n, k = map(int, input().split()) ###n:モンスターの数，k:必殺技の回数
h=sorted(list(map(int,input().split()))) ###h:モンスターの体力

if n<=k:
    print(0)
elif k==0:
    b=sum(h)
    print(b)
else:
    a=sum(h[:k+1])
    print(a)
def add_num(List):
  res=0
  for y in List:
    res += y
  print(res)

N, K=map(int,input().split())
List=list(map(int,input().split()))
if N <= K:
  print(0)
elif K != 0:
  x=List.index(max(List))
  List.pop(x)
  add_num(List)
else:
  add_num(List)
N, K = map(int, input().split())
list_H = [int(x) for x in input().split()]

list_H.sort()

list_H_left = list_H[:(-1)*K]

sum = 0
while list_H_left :
    sum += list_H_left[0]
    list_H_left.pop(0)

print(sum)
N, K = map(int, input().split())
H = list(map(int, input().split()))
H = sorted(H, reverse=True)
SUM = 0

if K >= N:
    print(0)
    exit()


    
for K in range(len(H)):
    SUM = SUM + H[K]

print(SUM)
n,k = map(int,input().split())
l = [int(i) for i in input().split()]
ls = sorted(l)
if k == 0:
  print(sum(l))
else:
  print(sum(l[:-k]))
#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))


H,K=input2()
h=input_array()

sorted_h=sorted(h)
if len(sorted_h)<1:
	print(0)
else:
	print(sum(sorted_h[:-K]))
N,K = map(int,input().split())
*H, = map(int,(input().split()))  
H.reverse()
if K <= len(H):
    del H[0:K]  
    print(sum(H))
else:
    print(0)
n, k = map(int, input().split())
h = list(map(int, input().split()))

h = sorted(h)
H = h[k:]
sum_ = sum(H)
print(sum_)
n,k = map(int, input().split())
h = list(map(int, input().split()))

h.sort()

h = h[k+1:]

print(sum(h))
n,k=map(int,input().split())
m = list(map(int,input().split()))
m.sort(reverse=True)
print(k+sum(m[k:]))
arr = input().split(" ")
N = int(arr[0])
K = int(arr[1])

HP_arr = input().split(" ")
HP_arr.sort(reverse=True)
HP_arr = [int(i) for i in HP_arr ]

if(K > 0):
    del HP_arr[:K]
    print(sum(HP_arr))
else:
    print(sum(HP_arr))
# Input(n = num of monsters/k = num of special attacks)
n, k = input().split()
a = list(map(int, input().split()))

# Variable declarations
n = int(n)
k = int(k)
attacks = 0

# Calculating how many attacks fennec needs.
for i in range(n-k):
    if k > n:
        print(0)
    attacks += a[i]

# Printing how many attacks fennec needs.
print(attacks)
n, k = map(int, input().split())
h = list(map(int,input().split()))
if k == 0:
    print(sum(h))
elif (n-k) > 0:
    m = max(h)
    h.remove(m)
    print(sum(h))
else:
    print("0")
x = [int(i) for i in input().split(" ")]
s = x[1]
m = [int(i) for i in input().split(" ")]
if s == 0:
  print(sum(m))
else:
  m = sorted(m)[0:-s:1]
  print(m)
H,K=input().split()
H=input()
H=H.split()
SUM=sum(int(i) for i in H)
A=(sorted(H, reverse=True)[:int(K)])
ASUM=sum(int(i) for i in A)
LO=int(SUM)-int(ASUM)
if(int(LO)<0):
  print(0)
else:
  print(LO)
N,K=map(int,input().split())
H=sorted(list(map(int,input().split())))
if (N<=K):
   print('O')
else:
   print(sum(H[:-K]))
n, k = map(int, input().split())
h = list(map(int, input().split()))
h.sort(reverse=True)
if len(h) <= k:
    print(0)
else:
    for _ in range(k):
        h.pop()
    print(sum(h))
n,k = map(int,input().split())
d = input().split()
d = [int(i) for i in d]

d.reverse()
del d[0:k]

print(sum(d))
N,K=map(int,input().split())
L=list(map(int,input().split()))
L=sorted(L)
print(sum(L[:K]))
N, K = map(int, input().split())
life = list(map(int, input().split()))

Nlife = sorted(life, reverse=True)


if K >= 1:
  del Nlife[:K-1]
  

answer = sum(Nlife)

print(answer)
N, K = map(int, input().split())
H = list( map(int, input().split()) )
H.sort()
import numpy as np
h = H[0:N-K]
#h = np.array(H[0:N-K])
print(sum(h))
H,K=input().split()
H=input()
H=H.split()
SUM=sum(int(i) for i in H)
A=(sorted(H, reverse=True)[:int(K)])
ASUM=sum(int(i) for i in A)
LO=int(SUM)-int(ASUM)
print(LO)
import numpy as np
N,K = map(int,input().split())
H = list(map(int,input().split()))
H.sort
j=0
if K >= N:
    print(N)
else:
    for i in range (N-K):
        j+=H[i]
    print(j)
n, k = map(int, input().split())
li = list(map(int, input().split()))

li.sort()
print(sum(li[:-k]))
N, K = [int(x) for x in input().split()]
H = [int(x) for x in input().split()]
H.sort()
H[N-1] = 0
print(sum(H))
import sys
sys.setrecursionlimit(100000000)
n, k = map(int , input().split())
h = list(map(int, input().split()))
count = 0
MOD = 1000000007
h.sort()
try:
    if(k != 0) : del h[-k]
    for i in h:
        count += i % MOD
    print(count)
except IndexError:
    count = 0
    print(count)
n,k=map(int,input().split())
h=sorted(map(int,input().split()))[::-1]
ans=0
for i in range(k+1,n-k):
  ans+=i
print(ans)
n,k,*a=map(int,open(0).read().split())
a.sort()
a+=[0]
print(sum(a[:~k])+k)
a = list(map(int,input().split()))
b = list(map(int,input().split()))

if len(b) <= a[1]:
    print("0")
elif a[1]==0:
    print(sum(b))
else:
    del b[a[0]-1]
    b.sort(reverse=True)
    print(sum(b[a[1]-1:]))
N,K = map(int,input().split())
H = [int(i) for i in input().split()]

H = sorted(H)
ans = sum(H[K+1:])
print(ans)
N, K = map(int, input().split())
H = list(map(int, input().split()))
sum = 0

H.sort()

H = H[0 : N - K]

for val in H:
  sum = sum + val
  
print(sum)
n,k=map(int,input().split())
#hp=list(map(int,input().split()))
hp=[int(x) for x in input().split()]
hp.sort()
if n>=k:
	re=sum(hp[:n-k])
else:
	re=sum(hp)
print(re)
N, K = [int(num) for num in input().split()]
H = [int(h) for h in input().split()]
H.sort()
K = -K
new_H = H[:K]
print(sum(new_H))
n, k = map(int, input().split())
h = list(map(int, input().split()))

INF = 1000000007
ans = 0

h.reverse()

if k>=len(h):
    print(0)

else:
    v = h[k:]
    for i in v:
        ans += i%INF
    print(ans)
n,k = map(int, input().split())
h = list(map(int, input().split()))
h.sort()
k = min(k,len(h))
del h[:k]
print(sum(h))
N, K = map(int, input().split())
H = list(map(int,input().split()))
if K <= 0:
    print(sum(H))
elif K >= N:
    print(0)
else:
    print(sum(H[:-K]))
N,K=map(int,input().split())
List=list(map(int,input().split()))
S=sorted(List)
if K==0 and len(List)==N:
    i=1
elif K!=0 and len(List)==N:
    i=0
del S[i:K+1]
print(sum(S))
n,k = map(int,input().split())
h = list(map(int,input().split()))

del h[n::]
h.sort()
if k != 0:
  del h[-k:]
print(h)
print(sum(h))
N, K = map(int, input().split())
H = list(map(int, input().split()))

H.sort()

cnt = 0
for i in range(N):
    if K > 0:
        K -= 1
    else:
        cnt += H[i]

print(cnt)
n, k = map(int, input().split())
h = list(map(int, input().split()))

h = sorted(h)

h = h[:-k]

print(sum(h))
N,K=map(int,input().split())
H=[int(i) for i in input().split()]
 
if K>=N:
  print(0)
else:
  I = sorted(H)
  x = 0
  for i in range(N-K):
    x += H[i]
  print(x)
N,K=[int(s) for s in input().split(" ")]
ListH=[int(s) for s in input().split(" ")]

#ListH.sort(reverse=True)
sum=0

if N<=K:
    print(0)
else:
    for i in range(K):
        ListH.remove(max(ListH))
        
    for i in range(N-K):
        sum+=ListH[i]

print(sum)
n,k = map(int,input().split())
l = [int(i) for i in input().split()]
ls = sorted(l)
print(sum(l[:-k]))
N, K = input().split(" ")
H = list(map(int, input().split()))
H.sort()
K = int(K)

if K > len(H):
	print(0)
else:
	print(sum(H[:-K]))
N, K = map(int,input().split())
H = list(map(int, input().split()))

if K >= N:
  print(0)
 
elif K == 0:
  print(sum(H))

else:
  H.sort
  print(sum(H[K-1:N-1]))
N, K = map(int,input().split())
H = list(map(int, input().split()))

if K >= N:
  print(0)
 
elif K == 0:
  print(sum(H))

else:
  H.sort
  print(sum(H[K-1:]))
#!/usr/bin/env python3
import numpy as np


DEBUG = True
dprint = print if DEBUG else lambda *x : x

N, K = [int(str) for str in input().strip().split()]
H = [int(str) for str in input().strip().split()]

if K == 0:
    print(sum(H))
elif K >= len(H):
    print(0)
else:
    H.sort(reverse=True)
    print(sum(H[:K]))
n, k = map(int, input().split())

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


h.sort()


k *= -1

del h[k:]

print(sum(h))
n,k=map(int,input().split())
h=list(reversed(list(map(int,input().split()))))
ans=0
for i in range(n):
    if(i>=k):
        ans+=h[i]
print(ans)
n, k = map(int, input().split())
h = list(map(int, input().split()))
print(sum(sorted(h)[:-k]))
n, k = map(int, input().split())
li = sorted(list(map(int, input().split())))
print(sum(li[:(n-k)]))
b,k=map(int,input().split())
h=list(map(int,input().split()))
h=sorted(h)
print(sum(h)-sum(h[-k:]))
H,N = list(map(int, input().split()))
A =list(map(int, input().split()))
A = sorted(A)
i = len(list(A))
if N == 0:
    print(sum(A))
else:
    if H > N:
        print(sum(A[0:(i-1)]))
    else:
        print(0)
N,K = map(int,input().split())
H = [int(x) for x in input().split()]
H.sort()

print(sum(H[0:N-K]))
N, K= map(int, input().split())
lists = list(map(int, input().split()))
lists.sort()
if K>=N:
  print(0)
else:
  del lists[-K:-1]
  SUM = sum(lists)
  print(SUM)
n,k = map(int, input().split())
H = sorted(list(map(int, input().split())))
print(sum(H[:-k]) if k >= n else 0)
a,b = map(int, input().split())
box = list(map(int, input().split()))
box.sort()
ans = sum(box[b:])
print(ans)
n, k = map(int, input().split())
h = list(map(int, input().split()))
h = sorted(h)
print(sum(sorted(h)[:n-k+1]))
N,K=map(int,input().split())
H=sorted(list(map(int,input().split())))
print(H[:N-K])
if len(H) < K:
    print(0)
else:
    print(sum(H[N-K:]))
a=input()
b=input()
c=a.split()
N=int(c[0])
K=int(c[1])
A=b.split()
ans=0
A.sort()
if(N<=K):print(0)
else:
    for i in range(N-K):
        ans = ans+int(A[K-1+i])
    print(ans)
def win(n,k,h):
    m=sorted(h)
    s=n-k
    sum1=0
    for i in range(s):
        sum1+=h[i]
    return sum1

#Driver code

n=3
k=1
h=[4,1,5]
print(win(n,k,h))
n, k = map(int, input().split())
h = list(map(int, input().split()))

if len(h) <= k:
	print(len(h))

else:
	h.sort(reverse = True)

	for i in range(0, k):
		h[i] = 0

	print(sum(h) + k)
N, K = map(int, input().split())
H = list(map(int, input().split()))
if K != 0:
    H = H[:-K]
print(sum(H))
n,k = list(map(int,input().split()))
h=list(map(int,input().split()))
h.sort()
print(sum(h[0:-k]))
# coding utf-8
import math
import sys


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

H = list(map(int, input().rstrip().split()))
H.sort()

if N > K:
    print(H[:-K])
    ans = sum(H)
else:
    ans = 0

print(ans)
N, K = list(map(int, input().split()))
H = list(map(int, input().split()))

# H を高い順にソート
# 上からK個削除
# SUM

sortedList = sorted(H)
s = 0
for i in range(N - K):
    s += H[i]

print(s)
n, k = map(int, input().split())
if k >= n:
    print(0)

h = []
h = list(map(int, input().split()))
h.sort()
if k == 0:
    sum_h = sum(h)
else:
    sum_h = sum(h[0:-k])
print(sum_h)
from heapq import heapify
N, K = map(int, input().split())
H = list(map(int, input().split()))

if K >= N:
    print(0)
else:
    heapify(H)
    while K > 0:
        H.pop(-1)
        K -= 1
    print(sum(H))
N, K = list(map(int, input().split()))
H = list(map(int, input().split()))

if K < N:
    H_sorted = sorted(H)
    print(sum(H_sorted[:-K]))
else:
    print(0)
#n = int(input())
n,k = map(int,input().split())
h_L = list(map(int,input().split()))

h_L.sort(reverse=True)
#print(h_L)
if k ==0:
    print(sum(h_L))
else:
    print(sum(h_L[k+1:]))
import numpy as np
n, k = map(int, input().split())
h = list(map(int, input().split()))
h = np.array(h)
if k >= n:
  print('0')
else:
  print(str(np.sum(h[:-k])))
n= int(input())
a = list(map(int, input().split()))
m = a[0]
j = 0
k = 1
for i in range(1,n):
    if a[i] <= m:
        m = a[i]
        k += 1
        j = i
print(k)
n = int(input())
p = list(map(int, input().split()))

c = 0
m = p[0]
for i in p:
    if m >= i:
        c += 1
        m = i

print(c)
n = input()
p = list(int(i) for i in input().split())
count = 1
min_num = min(p[0:1])
for i in range(1,len(p)):
  if(p[i] <= min_num):
    count += 1
    min_num = p[i]

print(count)
N = int(input())
P = list(map(int, input().split()))

min = P[0]
ans = 1
for i in range(1, N):
  if P[i] <= min:
    ans += 1
    min = P[i]
    
print(ans)
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
p = na()
m = p[0]
ans = 0
for i in range(n):
    #print(m, p[i])
    if m >= p[i]:
        ans += 1
    m = min(m, p[i])
print(ans)
N = int(input())
P = list(map(int,input().split()))

mi = P[0]
cnt = 1
for i in range(1,N):
    if P[i] <= mi:
        mi = P[i]
        cnt += 1
print(cnt)
n = int(input())
p = list(map(int,input().split()))
ans = 0
p_min = p[0]
for i in range(n):
    if p_min >= p[i]:
        ans += 1
        p_min = p[i]
print(ans)
n = int(input())
p = list(map(int, input().split()))
p_min = p[0]
ans = 1
for i in range(1, n):
    if p[i] <= p_min:
        ans += 1
        p_min = p[i]
print(ans)
n=int(input())
p=[int(x) for x in input().split()]
a=1
b=p[0]
for i in range(1,n):
  if p[i-1]<b:
    b=p[i-1]
  if p[i]<=b:
    a+=1
print(a)
def Convert(string): 
    li = list(map(int, string.split(" "))) 
    return li 

N = input().split()
L = Convert(input())
Min = L[0]
Sum = 0

for i in L:
    if i <= Min:
        Sum += 1
        Min = i
        

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

# 初期化
cnt = 1
min = p[0]
# カウント処理
for i in range(1, n):
  if(p[i] <= min):
    cnt += 1
    min = p[i]

print(cnt)
# -*- coding: utf-8 -*-
# C - Low Elements
import  sys

def solve152C(N, plist):
	
	count = 1
	maxnumber = plist[0]
	minnumber = plist[0]
	isFound = True
	for i in range(2, N+1):
		p = plist[i-1]
		if p < maxnumber and p < minnumber:
			count += 1
		
		if p > maxnumber:
			maxnumber = p
		if p < minnumber:
			minnumber = p
					
	print(count)


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

	solve152C(N, plist)
_ = int(input())
lp = list(map(int, input().split()))

m = 10 ** 6
answer = 0
for p in lp:
    m = min(m, p)
    answer += int(p <= m)

print(answer)
def solve():
    N, *P = map(int, open(0).read().split())
    
    ans = 0
    tmp = 10 ** 6
    for i in range(N):
        tmp = min(tmp, P[i])
        if P[i] <= tmp:
            ans += 1
    print(ans)


if __name__ == '__main__':
    solve()
n = int(input())
L = list(map(int,input().split()))
curmin = L[0]
cnt = 1
for i in range(1,n):
  if L[i] < curmin:
    cnt += 1
    curmin = L[i]
print(cnt)
#problem-c
n = int(input())
p = list(map(int, input().split()))
cnt = 0
min_p = p[0]
for i in range(n):
    if p[i]<=min_p:
        cnt += 1
        min_p = p[i]
print(cnt)
N = int(input())
P = list(map(int, input().split()))

ans = 0
min_num = N
for i in range(N):
    if P[i] <= min_num:
        ans += 1
        min_num = P[i]

print(ans)
N = int(input())
P = list(map(int, input().split()))

count = 1
mini = P[0]
for i in range(1, N):
    mini = min(mini, P[i])
    if P[i] <= mini:
        count += 1

print(count)
n=int(input())
p=list(map(int,input().split()))
min=200001
ans=0
for x in p:
  if min>x:
    min=x
    ans+=1
    if x==1:
      break

print(ans)
N = int(input())
P = list(map(int, input().split()))
 
result = 0
mini = [P[0]]
 
for i in range(N-1):
    if mini[i]>P[i+1]:
        mini.append(P[i+1])
    else:
        mini.append(mini[i])
 
for i in range(N):
    if P[i]==mini[i]:
        result += 1
 
print(result)
n = int(input())
num_list = list(map(int, input().split(" ")))
min = 200001
count = 0

for i in num_list:
    if min >= i:
        count += 1
        min = i

print(count)
n, a = input(), map(int, raw_input().split())
mi = n + 1
ans = 0
for i, x in enumerate(a):
    if mi > x:
        ans += 1
    mi = min(mi, x)
print ans
N = int(input())
P = list(map(int, input().split()))
count = 0
mini = P[0]
for p in P:
    if p <= mini:
        count += 1
    mini = min(mini, p)
print(count)
n=int(input())
P=list(map(int,input().split()))
M = P[0]
ans = 1
for p in P[1:]:
  if p <= M:
    ans+=1
    M=p
print(ans)
n = int(input())
p = list(map(int,input().split()))

min = p[0]
cnt = 1

for i in range(1,n):
    if min > p[i]:
        min = p[i]
        cnt += 1
            
print(cnt)
n = int(input())
p = list(map(int, input().split()))
minp = 2*10**5
ans = 0
for i in range(n):
    if minp >= p[i]:
        minp = p[i]
        ans += 1
print(ans)
N = int(input())
L = list(map(int, input().split()))

tmp = 10 ** 10
count = 0
for i in range(N):
    if tmp >= L[i]:
        count += 1
    tmp = min(tmp, L[i])
        
print(count)
N = int(input())
P = list(map(int, input().split()))

ans = 0
mn = 10**9
for i in range(N):
    if P[i] <= mn:
        mn = P[i]
        ans += 1
print(ans)
N = int(input())
A = list(map(int, input().split()))
s = 0
P = (A[0:N])
Q = A
for i in range(N-1):
    if Q[i] < Q[i+1]:
        Q[i+1] = Q[i]
for i in range(N):
    if P[i] == Q[i]:
        s += 1
print(s)