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

N = int(input())
A = list(map(int, input().split()))
sum = 0
# temp1 = 0
# temp2 = 0
MOD = 1000000007
for i in range(0, N-1):
    A[i] = A[i] % MOD
#print(A)
for i in range(0, N-1):
    for j in range(i+1, N):
        #print(i, j)
        temp1 = 0
        temp2 = 0
        temp3 = 0
        # temp1 = A[i] % MOD
        # temp2 = A[j] % MOD
        # temp3 = temp1 * temp2
        temp3 = (A[i] * A[j]) % MOD
        sum = (sum + temp3) % MOD
#sum = sum % MOD
print(sum)

### FIXED CODE ###

MOD = 1000000007
N = int(input())
A = list(map(int, input().split()))
ans = 0
B = [0]*(N-1)
sumA = sum(A)
for i in range(1, N):
    sumA -= A[i-1]
    B[i-1] = sumA
for i in range(0, N-1):
    ans += A[i] * B[i]
    ans %= MOD
print(ans)
### BUGGY CODE ###

def main():
    n, k = map(int, raw_input().split())
    a = []
    g = [[] for _ in xrange(n)]
    for _ in xrange(n - 1):
        u, v = map(int, raw_input().split())
        u -= 1
        v -= 1
        a.append((u, v))
        g[u].append(v)
        g[v].append(u)
    st = []
    pu = st.append
    po = st.pop
    ans = 0
    if k % 2:
        k = k / 2 + 1
        for u, v in a:
            c = 0
            pu((u, k, v))
            pu((v, k, u))
            while st:
                u, d, p = po()
                d -= 1
                c += 1
                if d:
                    for v in g[u]:
                        if v != p:
                            pu((v, d, u))
            if ans < c:
                ans = c
    else:
        k = k / 2 + 1
        for i in xrange(n):
            c = 0
            pu((i, k, -1))
            while c < len(st):
                u, d, p = st[c]
                d -= 1
                if d:
                    for v in g[u]:
                        if v != p:
                            pu((v, d, u))
                c += 1
            if ans < c:
                ans = c
            del st[:]
    print n - ans
main()


### FIXED CODE ###

def main(le=len):
    n, k = map(int, raw_input().split())
    a = []
    g = [[] for _ in xrange(n)]
    for _ in xrange(n - 1):
        u, v = map(int, raw_input().split())
        u -= 1
        v -= 1
        a.append((u, v))
        g[u].append(v)
        g[v].append(u)
    st = []
    pu = st.append
    po = st.pop
    ans = 0
    if k % 2:
        k = k / 2 + 1
        for u, v in a:
            c = 0
            pu((u, k, v))
            pu((v, k, u))
            while c < le(st):
                u, d, p = st[c]
                d -= 1
                if d:
                    for v in g[u]:
                        if v != p:
                            pu((v, d, u))
                c += 1
            if ans < c:
                ans = c
            del st[:]
    else:
        k = k / 2 + 1
        for i in xrange(n):
            c = 0
            pu((i, k, -1))
            while c < le(st):
                u, d, p = st[c]
                d -= 1
                if d:
                    for v in g[u]:
                        if v != p:
                            pu((v, d, u))
                c += 1
            if ans < c:
                ans = c
            del st[:]
    print n - ans
main()
### BUGGY CODE ###

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

def cost(i,j):
    return abs(h[i] - h[j])

dp=[0]*n
dp[0]=0

for i in range(1,n):
    lst=[]

    for j in range(i-k,i):
        if j>=0:
            lst.append(dp[j]+cost(j,i))
    dp[i]=min(lst)

print(dp[n-1])

### FIXED CODE ###

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

def cost(i,j):
    return abs(h[i] - h[j])

dp=[10**9]*n
dp[0]=0

for i in range(1,n):
    for j in range(i-k,i):
        if j>=0:
            cst = dp[j]+cost(j,i)
            if dp[i] > cst:
                dp[i]=cst

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

delta = ((1, 0), (0, 1), (-1, 0), (0, -1))
def ds(here, field, count, lb, ub, min_count):
	if count > min_count:
		return min_count
	ans = min_count
	for dx, dy in delta:
		neighbor = (here[0]+dx,here[1]+dy)
		nx, ny = neighbor
		while lb[0] <= nx <= ub[0] and lb[1] <= ny <= ub[1]:
			if field[ny][nx] == 1:
				if not(nx == neighbor[0] and ny == neighbor[1]):
					field[ny][nx] = 0
					ans = ds((nx-dx,ny-dy),field, count+1, lb, ub, ans)
		    		field[ny][nx] = 1
				break
			if field[ny][nx] == 3: 
				if count + 1 < ans:
					ans = count + 1
				break
			nx += dx
			ny += dy
	return ans
while 1:
	w, h = map(int,raw_input().split(" "))
	if w == h == 0: break
	board = [ map(int,raw_input().split(" ")) for _ in range(h)]
	for j in range(h):
		for i in range(w):
			if board[j][i] == 2:
				start = (i,j)
	result = ds(start, board, 0, (0,0), (w-1,h-1), 11)
	print result if result < 11 else -1

### FIXED CODE ###

delta = ((1, 0), (0, 1), (-1, 0), (0, -1))
def ds(here, field, count, lb, ub, min_count):
	if count == min_count:
		return min_count
	ans = min_count
	for dx, dy in delta:
		nx, ny = (here[0]+dx,here[1]+dy)
		neighbor = (nx, ny)
		while lb[0] <= nx <= ub[0] and lb[1] <= ny <= ub[1]:
			if field[ny][nx] == 1:
				if (nx, ny) != neighbor:
					field[ny][nx] = 0
					ans = ds((nx-dx,ny-dy),field, count+1, lb, ub, ans)
		    		field[ny][nx] = 1
				break
			if field[ny][nx] == 3:
				if count + 1 < ans:
					ans = count + 1
				break
			nx += dx
			ny += dy
	return ans
while 1:
	w, h = map(int,raw_input().split(" "))
	if w == h == 0: break
	board = [ map(int,raw_input().split(" ")) for _ in range(h)]
	for j in range(h):
		for i in range(w):
			if board[j][i] == 2:
				start = (i,j)
	result = ds(start, board, 0, (0,0), (w-1,h-1), 11)
	print result if result < 11 else -1
### BUGGY CODE ###

def gcd(x,y):
    if x==0:
        return y
    return gcd(y%x,x)    
x=int(input())
a=list(map(int,input().split()))
k=a[0]

for i in range(1,x):
    k=(k*a[i])//gcd(k,a[i])
s=0
mod=10**9+7
for i in a:
    s=(s+(k//i))%mod
print(s%mod)    

### FIXED CODE ###

from collections import defaultdict
import math
sieve=[1]*10001
i=2
while i*i<=10001:
    if sieve[i]:
        for j in range(i+i,10001,i):
            sieve[j]=0
        
    i+=1    
lol=[]
for i in range(2,10001):
    if sieve[i]:
        lol.append(i)
mod=10**9+7
def gcd(x,y):
    if x==0:
        return y
    return gcd(y%x,x)    
x=int(input())
a=list(map(int,input().split()))
d=defaultdict(int)
for i in a:
    k=0

    while lol[k]*lol[k]<=i:
        c=0
        #print("AScasc",i)
        j=lol[k]
        if i%j==0:    
            while i%j==0:
                i//=j
                c+=1
            d[j]=max(c,d[j])    
        k+=1    
    if i>=2:
        c=1
        d[i]=max(c,d[i])
        
y=0
s=d.keys()
#print(s,d)
z=1
for i in s:
    z*=pow(i,d[i])
for i in a:
    y+=((z%mod)*pow(i,mod-2,mod))%mod
print(y%mod)
### BUGGY CODE ###

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

    def move(lst):
        tmp = [0] * (N + 1)
        for i in range(N):
            a = lst[i]
            left = max(0, i - a)
            right = min(N, i + a + 1)
            tmp[left] += 1
            tmp[right] -= 1
        for i in range(N):
            tmp[i + 1] += tmp[i]
        for i in range(N):
            if lst[i] != N:
                return tmp
        print (*tmp[:-1])
        exit()

    for _ in range(K):
        A = move(A)
    print (*A[:-1])


if __name__ == '__main__':
    main()

### FIXED CODE ###

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

def check(lst):
    for i in range(N):
        if lst[i] != N:
            return False
    return True

def move(lst):
    tmp = [0] * (N + 1)
    for i in range(N):
        a = lst[i]
        left = max(0, i - a)
        right = min(N, i + a + 1)
        tmp[left] += 1
        tmp[right] -= 1
    for i in range(N):
        tmp[i + 1] += tmp[i]
    return tmp

for i in range(K):
    A = move(A)
    if check(A):
        # print (i)
        break

print (*A[:-1])
### BUGGY CODE ###

import fractions

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

def main():
    N, M = map(int, input().split())
    S = input()
    T = input()

    lcmn = lcm(N, M)
    l = ['' for i in range(lcmn+1)]
    for i in range(0, N):
        l[(lcmn//N)*i+1] = S[i]

    for i in range(0, M):
        if l[(lcmn//M)*i+1] != '' and l[(lcmn//M)*i+1] != T[i]:
            return -1

    return lcmn

print(main())

### FIXED CODE ###

import fractions

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

def main():
    N, M = map(int, input().split())
    S = input()
    T = input()

    L = lcm(N, M)
    ln = L//N
    lm = L//M
    n = {1+i*ln: s for i, s in enumerate(S)}
    m = {1+i*lm: t for i, t in enumerate(T)}
    
    for k in set(n.keys()).intersection(set(m.keys())):
        if n[k] != m[k]:
            return -1

    return L

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

N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

ans = 0
for k in range(K):
    dp = [[0] * 3 for i in range(N+1)]
    for i in range(N+1):
        # print(i)
        if k+i*K >= N:
            break

        if T[k+i*K] == 'r':
            dp[i+1][0] = max(dp[i][1], dp[i][2])
            dp[i+1][1] = max(dp[i][0], dp[i][2])
            dp[i+1][2] = max(dp[i][0]+P, dp[i][1]+P)

        elif T[k+i*K] == 's':
            dp[i+1][0] = max(dp[i][1]+R, dp[i][2]+R)
            dp[i+1][1] = max(dp[i][0], dp[i][2])
            dp[i+1][2] = max(dp[i][0], dp[i][1])

        else:
            dp[i+1][0] = max(dp[i][1], dp[i][2])
            dp[i+1][1] = max(dp[i][0]+S, dp[i][2]+S)
            dp[i+1][2] = max(dp[i][0], dp[i][1])
        # print(max(dp[i]))
    ans += max(dp[i])
print(ans)


### FIXED CODE ###

N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

dp = [[0] * 3 for i in range(N+1)]
for i in range(1, N+1):
    # print(i)

    if T[i-1] == 'r':
        if i < K:
            dp[i][0] = 0
            dp[i][1] = 0
            dp[i][2] = P
        else:
            dp[i][0] = max(dp[i-K][1], dp[i-K][2])
            dp[i][1] = max(dp[i-K][0], dp[i-K][2])
            dp[i][2] = max(dp[i-K][0]+P, dp[i-K][1]+P)

    elif T[i-1] == 's':
        if i < K:
            dp[i][0] = R
            dp[i][1] = 0
            dp[i][2] = 0
        else:
            dp[i][0] = max(dp[i-K][1]+R, dp[i-K][2]+R)
            dp[i][1] = max(dp[i-K][0], dp[i-K][2])
            dp[i][2] = max(dp[i-K][0], dp[i-K][1])

    else:
        if i < K:
            dp[i][0] = 0
            dp[i][1] = S
            dp[i][2] = 0
        else:
            dp[i][0] = max(dp[i-K][1], dp[i-K][2])
            dp[i][1] = max(dp[i-K][0]+S, dp[i-K][2]+S)
            dp[i][2] = max(dp[i-K][0], dp[i-K][1])
    # print(max(dp[i]))
ans = 0
for i in range(K):
    ans += max(dp[N-i])
print(ans)
### BUGGY CODE ###

s = list(input())
nb = s.count("B")
l = len(s)
ret = 0 
for i in range(nb):
    for j in range(l-i):
        if s[-(j+i+1)]=="B":
            ret += j
            s[-(j+i+1)]="W"
            break
print(ret)

### FIXED CODE ###

s = list(input())
s.reverse()
wl = 0 
rwl = 0 
ret = 0 
l = len(s)
for i in range(l):
    if s[i] == "W":
        wl += 1
    else:
        ret += rwl + wl
        rwl += wl
        wl = 0 
print(ret)
### BUGGY CODE ###

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

st_list = ['R', 'G', 'B']
ans = 0
for i, i_s in enumerate(s):
    first = [i, i_s]
    s_2 = s[i+1:]
    
    for j, j_s in enumerate(s_2):
        if (first[1]!=j_s):
            second = [j, j_s]
            s_3 = s_2[j+1:]
        else:
            continue

        for st_ in st_list:
            if (st_ != first[1] and st_ != second[1]):
                search_w = st_
	
        ans += s_3.count(search_w)
        if len(s_3) > second[0]:
            if s_3[second[0]] == search_w:
                ans -= 1

print(ans)

### FIXED CODE ###

import itertools
N = int(input())
S = input()
out = S.count('R') * S.count('G') * S.count('B')

RGBs = list(itertools.permutations(['R', 'G', 'B'], 3))
for i in range(1, N):
  for j in range(N-i*2):
    if (S[j], S[j+i], S[j+i*2]) in RGBs:
      out -= 1
print(out)
### BUGGY CODE ###

# D - Xor Sum 2
# https://atcoder.jp/contests/arc098/tasks/arc098_b

import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline() for _ in range(n)]

def main(N, An):
    ans = N
    for l in range(N):
        for r in range(l+1, N):
            a = An[l]
            b = An[l]
            for i in range(l+1, r+1):
                a ^= An[i]
                b += An[i]
            if a == b:
                ans += 1
    print(ans)

N = i2n()
An = i2nn()
main(N, An)



### FIXED CODE ###

# D - Xor Sum 2
# https://atcoder.jp/contests/arc098/tasks/arc098_b

import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline() for _ in range(n)]

def main_lte(N, An):
    ans = N
    for l in range(N):
        for r in range(l+1, N):
            a = An[l]
            b = An[l]
            for i in range(l+1, r+1):
                a ^= An[i]
                b += An[i]
            if a == b:
                ans += 1
    print(ans)

def main_lte2(N, An):
    ans = N
    for l in range(N):
        a = An[l]
        b = An[l]
        for r in range(l+1, N):
            a ^= An[r]
            b += An[r]
            if a == b:
                ans += 1
            else:
                continue
    print(ans)

def main(N, An):
    ans = 0
    n = 0
    l = 0
    for r in range(N):
        n2 = An[r]
        if n & n2 == 0:
            n += n2
        else:
            while True:
                n -= An[l]
                l += 1
                if n & n2 == 0:
                    n += n2
                    break
        ans += r + 1 - l
    print(ans)

N = i2n()
An = i2nn()
main(N, An)
### BUGGY CODE ###

S=input()
Q=int(input())
ans=0
for i in range(Q):
    q=input()
    if q[0]=='2':
        if ans%2==0:
            if q[2]=='1':
                S=q[4]+S
            else:
                S=S+q[4]
        else:
            if q[2]=='1':
                S=S+q[4]
            else:
                S=q[4]+S
    else:
        ans+=1
print(S if ans%2==0 else S[::-1])

### FIXED CODE ###

from collections import deque
S=deque(input())
Q=int(input())
ans=0
for i in range(Q):
    q=input()
    if q[0]=='2':
        if ans%2==0:
            if q[2]=='1':
                S.appendleft(q[4])
            else:
                S.append(q[4])
        else:
            if q[2]=='1':
                S.append(q[4])
            else:
                S.appendleft(q[4])
    else:
        ans+=1
S="".join(S)
print(S if ans%2==0 else S[::-1])
### BUGGY CODE ###

# coding: utf-8
import os
from sys import stdin
from functools import total_ordering

# __dirname = os.path.dirname(__file__)
# __basename = os.path.splitext(os.path.basename(__file__))[0]
# __targetname = './input/' + __basename + '.txt'
# target_path = os.path.join(__dirname, __targetname)
# stdin = open(target_path)


def main():
    A, B = map(int,stdin.readline().rstrip().split(' '))
    ans = 0
    for x in range(A,B+1):
        ans ^= x
    print(ans)

if __name__ == "__main__":
    main()
    

### FIXED CODE ###

# coding: utf-8
import os
from sys import stdin, stdout

__LOCAL__ = False
if(__LOCAL__):
    __dirname = os.path.dirname(__file__)
    __basename = os.path.splitext(os.path.basename(__file__))[0]
    __inputname = './input/' + __basename + '.txt'
    __outputname = './output/' + __basename + '.txt'
    input_path = os.path.join(__dirname, __inputname)
    output_path = os.path.join(__dirname, __outputname)
    stdin = open(input_path)
    stdout = open(output_path, "w")

def TLEmain():
    A, B = map(int,stdin.readline().rstrip().split(' '))
    ans = 0
    for x in range(A,B+1):
        ans ^= x
    print(ans)

def xorsum(A):
    if(A&1):
        return (A+1)//2 & 1
    else:
        return ((A+1)//2 & 1) ^ A

def main():
    A, B = map(int,stdin.readline().rstrip().split(' '))
    if(A==B):
        ans = A
        stdout.write("{}\n".format(ans))
    else:
        ans = xorsum(A-1)^xorsum(B)
        stdout.write("{}\n".format(ans))     

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

x,y,z,k=map(int,input().split())
a=[int(i)for i in input().split()]
b=[int(i)for i in input().split()]
c=[int(i)for i in input().split()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
ans=[]
for A in a:
    for B in b:
        ans+=[A+B]
ans.sort(reverse=True)
ANS=[]
for K in ans[:k]:
    for C in c:
        ANS+=[C+K]
ANS.sort(reverse=True)
for i in range(k):
    print(ANS[i])

### FIXED CODE ###

def ca():
    x,y,z,k=map(int,input().split())
    a=[int(i)for i in input().split()]
    b=[int(i)for i in input().split()]
    c=[int(i)for i in input().split()]
    c.sort(reverse=True)
    AB=[i+j for i in a for j in b]
    AB.sort(reverse=True)
    ans=[i+j for i in AB[:k]for j in c]
    ans.sort(reverse=True)
    for i in ans[:k]:
        print(i)
    exit()
print(ca())
### BUGGY CODE ###

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

r = [i for i in range(n) if s[i] == 'R']
g = [i for i in range(n) if s[i] == 'G']
b = [i for i in range(n) if s[i] == 'B']
rgb = [sorted([ri, gi, bi]) for ri in r for gi in g for bi in b]

count = 0
for [i, j, k] in rgb:
    if j - i != k - j:
        count += 1
        
print(count)

### FIXED CODE ###

input()
s = input()

r, g, b = map(s.count, 'RGB')

print(r * g * b - sum(1 for i, c1 in enumerate(s) for j, c2 in enumerate(s[i::2]) if c1 != c2 != s[i + j] != c1))
### BUGGY CODE ###

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

n = int(input())
a = list(map(int, input().split()))

lis = {}
lis2= [0]*(10**6+1)
flg1 = True

for i in range(n):
  temp =  make_divisors(a[i])
  for j in temp:
    if j == 1:
      continue
    """
    if not  j in lis:
      lis[j]=1
    else:
      flg1 = False
      lis[j]+=1
      if lis[j]==n:
        print("not coprime")
        quit()
    """
    lis2[j]+=1
    if lis2[j]>1:
      flg1 = False
      if lis2[j]==n:
        print("not coprime")
        quit()
    

if flg1:
  print("pairwise coprime")
else:
  print("setwise coprime")



### FIXED CODE ###

from math import gcd
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return set(a)
  
n = int(input())
a = list(map(int, input().split()))
dic = {}
g = a[0]
flg = True
for i in range(n):
  g = gcd(g, a[i])
  if flg:
    tmp = prime_factorize(a[i])
    for j in tmp:
      if j in dic:
        flg = False
      else:
        dic[j]=1
        
if flg:
  print("pairwise coprime")
elif g == 1:
  print("setwise coprime")
else:
  print("not coprime")
### BUGGY CODE ###

a, b, c, d = map(int, input().split())
count = 0
for i in range(a,b+1):
        if i % c != 0 and i % d != 0:
                count += 1
print(count)

### FIXED CODE ###

def gcd(x,y):
        while y != 0:
                x, y = y, x%y
        return x

a, b, c, d = map(int, input().split())
g = gcd(c,d)
b_count = b - b//c - b//d + b//(c*d//g)
a_count = (a-1) - (a-1)//c - (a-1)//d + (a-1)//(c*d//g)
print(b_count-a_count)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
amount = [0]*n

for i in range(n):
    amount[i] = a.count(i+1)

for j in range(n):
    ans = 0
    for k in range(n):
        if a[j] == k+1:
            ans += (amount[k]-1)*(amount[k]-2)//2
        else:
            ans += amount[k]*(amount[k]-1)//2
    print(ans)

### FIXED CODE ###

import numpy as np
def main():
    from collections import Counter
    n = int(input())
    a = tuple(map(int, input().split()))
    ans = 0
    c = Counter(a)
    for i in range(n):
        ans += c[i+1]*(c[i+1]-1)//2
    for j in range(n):
        print(ans - c[a[j]] + 1)
if __name__ == '__main__':
    main()
### BUGGY CODE ###

s=input()
K=int(input())
s_set=set([])
for i in range(len(s)):
    for j in range(i,len(s)):
        s_set.add(s[i:j+1])
L=sorted(list(s_set))
print(L[K-1])

### FIXED CODE ###

s=input()
K=int(input())
s_set=set([])
for i in range(len(s)):
    for j in range(i,len(s)):
        if len(s[i:j+1])<=K:
            s_set.add(s[i:j+1])
L=sorted(list(s_set))
print(L[K-1])
### BUGGY CODE ###

K,S=map(int,input().split())
n=0
for X in range(0,K+1):
  for Y in range(0,K+1):
    for Z in range(0,K+1):
      if S==X+Y+Z:
        n+=1
print(n)

### FIXED CODE ###

K,S=map(int,input().split())
n=0
for X in range(0,K+1):
  for Y in range(0,K+1):
      if 0<=S-X-Y<=K:
        n+=1
print(n)
### BUGGY CODE ###

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

a = [0]*n
for i in range(n):
  a[i]=lst.count(i+1)
a.sort(reverse=True)
ans = 0
for i in range(k):
  if a[i] == 0:
    ans = n
  else:
    ans += a[i]
print(n-ans)

### FIXED CODE ###

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

num = []
cnt = []

for i in range(N):
    if i == 0:
        num.append(A[i])
        cnt.append(1)
    else:
        if A[i-1] != A[i]:
            num.append(A[i])
            cnt.append(1)
        else:
            cnt[-1] += 1
cnt.sort()
#print(num,cnt)

res = 0
M = len(cnt)
if M <= K:
    res = 0
else:
    for i in range(M-K):
        res += cnt[i]
print(res)
### BUGGY CODE ###

l,r = map(int,input().split())
r = min(r, l+4038)
ans = 2018
for i in range(l,r):
    for j in range(l+1,r+1):
        if ans > i*j%2019:
            ans = i*j%2019
print(ans)

### FIXED CODE ###

l,r = map(int,input().split())
r = min(r, l+4038)
ans = 2018
for i in range(l,r):
    for j in range(l+1,r+1):
        if ans > i*j%2019:
            ans = i*j%2019
print(ans)
### BUGGY CODE ###

import math as m
N,M = map(int,input().split())
# N == 1 の処理
if N == 1:
    print(M)
    exit()
# Mの素数判定
judge = "prime"
for i in range(2,m.floor(pow(M,1/2)) + 1):
    if M % i == 0:
        judge = "conposite"
        break
if judge == "prime":
    print(1)
    exit()
for i in range(M // N,0,-1):
    if M % i == 0:
        print(i)
        exit()

### FIXED CODE ###

import math as m
N,M = map(int,input().split())
# N == 1 の処理
if N == 1:
    print(M)
    exit()
# Mの素数判定
judge = "prime"
for i in range(m.floor(pow(M,1/2)),1,-1):
    if M % i == 0:
        judge = "conposite"
        break
if judge == "prime":
    print(1)
    exit()
for i in range(M // N,0,-1):
    if M % i == 0:
        print(i)
        exit()
### BUGGY CODE ###

from functools import reduce
n = int(input())
s = list(input())
def count_combination(x):
    if sum(x) != n:
        return(0)
    total_count = 1
    false_count = 0
    for i in range(2*n):
        if x[i]:
            total_count *= false_count
            false_count -= 1
        else:
            false_count += 1
        if false_count == -1:
            return(0)
    return(total_count)
sb = list(map(lambda x: False if x == 'W' else True, s))
sb[::2] = list(map(lambda x: not x, sb[::2]))

total_count = count_combination(sb)

permutation = reduce(lambda x, y: x*y, range(1,n+1))

print(total_count * permutation % (10**9+7))

### FIXED CODE ###

from functools import reduce
n = int(input())
s = list(input())
def count_combination(x):
    if sum(x) != n:
        return(0)
    total_count = 1
    false_count = 0
    for i in range(2*n):
        if x[i]:
            total_count = total_count*false_count%(10**9+7)
            false_count -= 1
        else:
            false_count += 1
        if false_count == -1:
            return(0)
    return(total_count)
sb = list(map(lambda x: False if x == 'W' else True, s))
sb[::2] = list(map(lambda x: not x, sb[::2]))

total_count = count_combination(sb)

permutation = reduce(lambda x, y: x*y%(10**9+7), range(1,n+1))

print(total_count * permutation % (10**9+7))