Harryxun/stf_run huggingface dataset:
N, K = input().split('')
N = int(N)
K = int(K)
h_list = input().split('')
h_list = [int(x) for x in hlist]

# N=1
# K=500
# h_list=[499]

person = 0
for n in range(N):
    if h_list[n] >= K:
        person+=1
    
print(person)

### FIXED CODE ###

N, K = (int(i) for i in input().split())  
h_list = [int(i) for i in input().split()] 

person = 0
for n in range(N):
    if int(h_list[n]) >= K:
        person+=1
    
print(person)
l=input()
w=""
c=1
while len(w)<len(l):
  w+=l[c]
  c+=2
print(w)
  

### FIXED CODE ###

l=input()
w=""
c=0
while len(w)<len(l)/2:
  w+=l[c]
  c+=2
print(w)
def count_section_by_zero(data):
  count = 0
  flg = False
  start = 0
  for i, d in enumerate(data):
    if flg is False and d != 0:
      count += 1
      flg = True
      
    if d == 0:
      flg = False
  return count

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

def input_list_str():
  return list(map(str, input().split()))

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

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

# 2で割り切れる回数
def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c

# 素因数分解
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 a

def main():
  n = int(input())
  nums = []
  for i in range(n):
    nums.append(int(input()))
  
  min_num = min(nums)
  print(math.ceil(n/min_num)+4)
  
import math
import fractions
import collections
import itertools
from functools import reduce
main()

### FIXED CODE ###

N = int(input())

A = []
for _ in range(5):
  A.append(int(input()))
  
import math
L = math.ceil(N/min(A))

print(5 + L - 1)
import math
a,b,h,m = map(int,input().split())
ans = 0
ang = 0

if 6*m == 30*h+0.5*m:
  ans = 1
elif abs(6*m - 30*h+0.5*m) == 180:
  ans = 7
  ang = 180
elif 6*m > 30*h+0.5*m:
  ang = 6*m - 30*h+0.5*m
  ans = sqrt(a**2+b**2-2*a*b*math.cos(ang))
else:
  ang = 30*h+0.5*m + (360 - 6*m)
  if ang > 360:
    ang -= 360
  ans = math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(ang)))
print(ans)

### FIXED CODE ###

import math
a,b,h,m = map(int,input().split())
ans = 0
ang = 0
tan = 30*h+0.5*m
cho = 6*m
ang = abs(cho-tan)
#print(tan,cho,ang)

ans = math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(ang)))
print(ans)
x=input()
if x == 'hi'
	print('Yes')
else if x == 'hihi'
	print('Yes')
else if x == 'hihihi'
	print('Yes')
else if x == 'hihihihi'
	print('Yes')
else if x == 'hihihihihi'
	print('Yes')
else
	print('NO')

  

### FIXED CODE ###

x=input()
if x == 'hi':
	print('Yes')
elif x == 'hihi':
	print('Yes')
elif x == 'hihihi':
	print('Yes')
elif x == 'hihihihi':
	print('Yes')
elif x == 'hihihihihi':
	print('Yes')
else:
	print('No')
N, = map(int, input().split())
A = map(int, input().split())
from collections import defaultdict
d = defaultdict(int)
for a in A:
    d[a] += 1
r = 0
for a in d:
    if a > d[a]:
        r += d[a]
    else:
        r += d[a]-a
print(r)


### FIXED CODE ###

N, K = map(int, input().split())
X = map(int, input().split())
from collections import defaultdict
d = defaultdict(int)
for x in X:
    d[x] += 1

l = sorted(list(d.values()))
print(sum(l[:max(0, len(l)-K)]))
import numpy as np
h,w=map(int,input().split())
box=[["."]+list(input())+["."] for i in range(h)]
box.insert(0,["."]*(w+2))
box.append(["."]*(w+2))
count=0
def seek(box,i,j):
    point=[[1,0],[-1,0],[0,1],[0,-1]]
    if box[i][j]=="#":
        for x,y in point:
            xx=x+i
            yy=y+j
            if box[xx][yy]=="#" or box[xx][yy]=="O":
                box[i][j]="O"
                seek(box,xx,yy)
    return box
for i in range(1,h+1):
    for j in range(1,w+1):
        seek(box,i,j)

for i in range(1,h+1):
    for j in range(1,w+1):
        if box[i][j]=="#":print("No");exit()

print("Yes")

### FIXED CODE ###

H, W = map(int, input().split())
s = [input() for i in range(H)]
for i in range(H):
    for j in range(W):
        if s[i][j] == ".":
            continue
        if i == 0 or s[i-1][j] == "#":
            continue
        if i == H-1 or s[i+1][j] == "#":
            continue
        if j == 0 or s[i][j-1] == "#":
            continue
        if j == W-1 or s[i][j+1] == "#":
            continue
        print("No")
        exit()
print("Yes")
import numpy as np

A, B = map(int, input().split())

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

n = gcd(A, B)

is_prime = np.array([True] * (n + 1))
is_prime[0] = False
is_prime[1] = True

for i in range(2, int(n**0.5) + 1):
    if is_prime[i]:
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False

take_l = [i for i in range(1, n + 1) if is_prime[i] and n%i == 0]
print(len(take_l))

### FIXED CODE ###

A, B = map(int, input().split())

# 最大公約数
def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x

GCD = gcd(A, B)

# 最大公約数の素因数を求める
prime_factor = []

# 素因数で可能な限り割る
def divide_by_prime_factor(GCD, p):
    if GCD%p == 0:
        prime_factor.append(p)
        while GCD%p == 0:
            GCD /= p
    return GCD, prime_factor

GCD, prime_factor = divide_by_prime_factor(GCD, 2)

for i in range(3, int(GCD**0.5)+1, 2):
    GCD, prime_factor = divide_by_prime_factor(GCD, i)

# GCDそれ自身が素数の場合を考慮。GCD==1の場合を除くことに注意
if GCD > 2:
    GCD, prime_factor = divide_by_prime_factor(GCD, GCD)

# 素因数の数+1を出力
print(len(prime_factor)+1)
n = int(input())
d = [0]*(10**5+1)
for i in range(n):
    a = int(input())
    d[a] += 1
ans = 0
for i in d:
    if i%2==1:
        ans += 1
print(ans)

### FIXED CODE ###

import collections
n = int(input())
a = [int(input()) for _ in range(n)]
c = collections.Counter(a)
ans = 0
for i in c:
    if c[i]%2==1:
        ans += 1
print(ans)
dk = {}
dk["a"] = input()
dk["b"] = input()
dk["c"] = input()

n = "a"
while True:
    if len(dk[n]) == 0:
        print(n.upper())
        break
    nn = dk[n][0]
    dk[n] = dk[n][1:]
    n = nn



### FIXED CODE ###

a = int(input())
b = int(input())
h = int(input())

print("%d" % ((a+b)*h/2))
H, W = map(int, input().split())
S = ["..................................................."]
for i in range(H):
    S.append(input())
for i in range(H+1):
    S[i] = '.' + S[i] + '.'
S.append("...................................................")
ans = [[0] * W for i in range(H)]

for i in range(1,H+1):
    for j in range(1,W+1):
        if S[i][j] == '#':
            ans[i-1][j-1] = '#'
        else:
            count = []
            for a in range(i-1, i+2):
                for b in range(j-1, j+2):
                    count.append(S[a][b])
            ans[i-1][j-1] = count.count('#')

for i in range(H):
    yoko = ''
    for j in range(W):
        yoko += str(ans[i][j])
    print(yoko)

### FIXED CODE ###

H, W = map(int, input().split())
S = ["........................................................"]
for i in range(H):
    S.append(input())
for i in range(H+1):
    S[i] = '.' + S[i] + '.'
S.append("........................................................")
ans = [[0] * W for i in range(H)]

for i in range(1,H+1):
    for j in range(1,W+1):
        if S[i][j] == '#':
            ans[i-1][j-1] = '#'
        else:
            count = []
            for a in range(i-1, i+2):
                for b in range(j-1, j+2):
                    count.append(S[a][b])
            ans[i-1][j-1] = count.count('#')

for i in range(H):
    yoko = ''
    for j in range(W):
        yoko += str(ans[i][j])
    print(yoko)
a, b = map(int, input().split())
c, d = map(int, input().split())
if (a*b)==(c*d):
 print((a*b)-(c*d))
elseif (a*b ) > (c*d):
  print((c*d))

### FIXED CODE ###

a, b = map(int, input().split())
c, d = map(int, input().split())
print((a-c)*(b-d))
from math import factorial as fct
def main():
    MOD = 10**9 + 7
    N, K = map(int, input().split())
    b = K
    r = N - K
    for i in range(1, K+1):
        p_blue = int(fct((b-i)+(i-1)) / fct(b-i) / fct(i-1)) % MOD
        if r >= i-1:
            p_red = int(fct((r-(i-1))+i) / fct(r-(i-1)) / fct(i)) % MOD
        else:
            p_red = 0
        print((p_blue * p_red) % MOD)
main()

### FIXED CODE ###

from math import factorial as fct
def main():
    MOD = 10**9 + 7
    N, K = map(int, input().split())
    b = K
    r = N - K
    for i in range(1, K+1):
        p_blue = (fct((b-i)+(i-1)) // fct(b-i) // fct(i-1)) % MOD
        if r >= i-1:
            p_red = (fct((r-(i-1))+i) // fct(r-(i-1)) // fct(i)) % MOD
        else:
            p_red = 0
        print((p_blue * p_red) % MOD)
main()
x, a, b = map(int, input.split())
print("A" if max(x, a) - min(x, a) < max(x, b) - min(x, b) else "B")

### FIXED CODE ###

x, a, b = map(int, input().split())
print("A" if max(x, a) - min(x, a) < max(x, b) - min(x, b) else "B")
import numpy as np
s=input()
A=np.zeros(4)
B=np.zeros(4)
C=np.zeros(4)
t=0
for c in s:
	if c=="A":
		A[0]+=1
	if c=="B":
		B+=A
	if c=='C':
		C+=B
	if c=='?':
		C+=np.roll(B,1)
		B[1]+=A[0]
		B[2]+=A[1]
		A[1]+=1
		t+=1
ans=0
for i in range(4):
	ans+=pow(3,t-i)*C[i]
print(int(ans%1000000007))

### FIXED CODE ###

#a,b=map(int,input().split())
import numpy as np

s=input()
n=len(s)
wayA=np.array([0,0,0,0],dtype=np.int64)
wayB=np.array([0,0,0,0],dtype=np.int64)
wayC=np.array([0,0,0,0],dtype=np.int64)
hatena=0
MOD=1000000007
for c in s:
	if c=="A":
		wayA[0]=wayA[0]+1
	if c=="B":
		wayB+=wayA;
	if c=='C':
		wayC=wayC+wayB
	if c=='?':
		wayC[1]=wayC[1]+wayB[0]
		wayC[2]=wayC[2]+wayB[1]
		wayC[3]=wayC[3]+wayB[2]
		wayB[1]=wayB[1]+wayA[0]
		wayB[2]=wayB[2]+wayA[1]
		wayA[1]=wayA[1]+1
		hatena=hatena+1
	for z in range(0,4):
		wayA[z]=wayA[z]%MOD
		wayB[z]=wayB[z]%MOD
		wayC[z]=wayC[z]%MOD
ans=0
for i in range(0,4):
	p3=1
	if wayC[i]<=0:
		continue
	for k in range(0,hatena-i):
		p3=p3*3
		p3=p3%MOD
	ans=ans+p3*wayC[i]
	ans=ans%MOD
print(int(ans))
R=input()
if R<1200:
  print("ABC")
elif R<2800:
  print("ARC")
else:
  print("AGC")

### FIXED CODE ###

r = int(input())
if r<1200:
  print("ABC")
elif r<2800:
  print("ARC")
else:
  print("AGC")
from sys import stdin

N, L = stdin.readline().rstrip()

# N, L = 5, 2
# N, L = 3, -1
# N, L = 30, -50

min_value = L
max_value = L + N - 1

summation = L * N + sum(range(N))

if (min_value < 0) and (0 < max_value):
    pass
elif (min_value > 0):
    summation -= min_value
elif (max_value < 0):
    summation -= max_value
    
print(summation)    

### FIXED CODE ###

from sys import stdin

# N, L = stdin.readline().rstrip()
N, L = map(int, input().split(' '))
# print(N, L)
# N, L = 5, 2
# N, L = 3, -1
# N, L = 30, -50

min_value = L
max_value = L + N - 1

summation = L * N + sum(range(N))

if (min_value < 0) and (0 < max_value):
    pass
elif (min_value > 0):
    summation -= min_value
elif (max_value < 0):
    summation -= max_value
    
print(summation)
total=0
count=0

for l in range(A+1):
    for m in range(B+1):
        for n in range(C+1):
            total=500*l + 100*m + 50*n
            print(total)
            if(total==X): count += 1
                
print(count)

### FIXED CODE ###

A = int(input())
B = int(input())
C = int(input())
X = int(input())

total=0
count=0

for l in range(A+1):
    for m in range(B+1):
        for n in range(C+1):
            total=500*l + 100*m + 50*n
            if(total==X): count += 1
                
print(count)
n = int(input())
line = list(map(int, input()))
ans = [0 for i in range(n)]
for i in range(n):
  ans[line[i-1]] = i+1
print(' '.join(ans))

### FIXED CODE ###

n = int(input())
line = list(map(int, input().split()))
ans = ['0' for i in range(n)]
for i in range(n):
  ans[line[i]-1] = str(i+1)
print(' '.join(ans))
n = int(input())
al = [int(input()) for _ in range(n)]

pos = 0
for i in range(N):
    pos = A[pos] - 1
    if (pos == 1):
        print(i+1)
        exit()
print(-1)


### FIXED CODE ###

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

pos = 0
for i in range(n):
    pos = al[pos] - 1
    if (pos == 1):
        print(i+1)
        exit()
print(-1)
n = input().split()
a = int(n[0])
b = int(n[1])

print('{} {}'.format(a*b,2*a+2*b)

### FIXED CODE ###

a,b = map(int,input().split())
s = a * b
l = 2*a + 2*b

print(s,l)
from itertools import combinations_with_replacement
import numpy as np

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

G = [list(map(int, input().split())) for _ in range(Q)]

ans = 0

# 可能な数列Aの全探索、そのままやとめちゃ多いからなんか工夫する？
# そもそもAの全探索方がいまいちわからん...

A = np.array(list(itertools.combinations_with_replacement(range(1, M + 1), N)))
scores = np.zeros(len(A))
for g in G:
    a, b, c, d = g
    cond = A[:, b - 1] - A[:, a - 1] == c
    scores += d * cond

print(scores.max())

### FIXED CODE ###

from itertools import combinations_with_replacement
import numpy as np

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

G = [list(map(int, input().split())) for _ in range(Q)]

ans = 0

# 可能な数列Aの全探索、そのままやとめちゃ多いからなんか工夫する？
# そもそもAの全探索方がいまいちわからん...

A = np.array(list(combinations_with_replacement(range(1, M + 1), N)))
scores = np.zeros(len(A), dtype=np.int32)
for g in G:
    a, b, c, d = g
    cond = A[:, b - 1] - A[:, a - 1] == c
    scores += d * cond

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


### FIXED CODE ###

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

a.sort()
cnt = 1
ans = 0
for i in range(len(a)-1):
    if a[i] == a[i+1]:
        cnt += 1
        continue

    if cnt >= a[i]:
        ans += cnt - a[i]
    else:
        ans += cnt
    cnt = 1
if cnt >= a[-1]:
    ans += cnt - a[-1]
else:
    ans += cnt
print(ans)
import math

def main():
  R = input()
  answer = R * 2 / math.pi
  print(answer)
  
if __name__ == '__main__':
  main()

### FIXED CODE ###

import math

def main():
  R = input()
  answer = float(R) * 2 * math.pi  
  print(answer)
  
if __name__ == '__main__':
  main()
print(48 - int(input())

### FIXED CODE ###

M = int(input())
print(48 -M)
if __name__ == '__main__':

    n,q = map(int,raw_input().split())
    s = raw_input()

    for i in range(q):
        left,right = map(int,raw_input().split())

        for j in range(left-1,right-1):
            if s[j] == 'A' and s[j+1] == 'C':
                count += 1
        else:
            print count

### FIXED CODE ###

def get_ac(n,q,s,l,r):
    pos = [0]*n

    for j in range(0,n-1):
        if s[j] == 'A' and s[j+1] == 'C':
            pos[j+1] = pos[j] + 1
        else:
            pos[j+1] = pos[j]

    for i in range(q):
        left = l[i]
        right = r[i]
        count = pos[right - 1] - pos[left - 1]

        print count

if __name__ == '__main__':

    n,q = map(int,raw_input().split())
#    t1 = time.time()
    s = raw_input()

    l = [0]*q
    r = [0]*q

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

#    t2 = time.time()
#    print('{0:.9f}'.format(t2 - t1))
    get_ac(n,q,s,l,r)
from operator import mul
from functools import reduce

def comb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
inf = 10 ** 9 + 7
n, k = map(int, input().split())
for i in range(k):
    print(int(comb(n + 1 - k, i + 1) * comb(k - 1, i) % inf))

### FIXED CODE ###

mod = 10 ** 9 + 7
n, k = map(int, input().split())
red, blue = n-k, k
ai = red + 1
print(ai)
for i in range(2, blue+1):
    ai = ai * (red-i+2) * (blue-i+1) // (i*(i-1))
    print(ai % mod)
def main():
  if 'get_ipython' not in globals():  
    # For Subsession
    N,K = map(int, input().split())
    h = []
    for _ in range(N):
      h.append(int(input()))
  else:
    # N = 5
    # K = 3
    # h = [10,15,11,14,12]
    N = 5
    K = 3
    h = [5,7,5,7,7]

  h.sort()
  for i in range(0,len(h)-K+1):
    if i == 0:
      ans = 0
      for n in range(0,K-1):
        ans += (h[n+1] - h[n])
    else:
      tmp = 0
      for n in range(i, i+K-1):
        tmp += (h[n+1] - h[n])
      if ans > tmp:
        ans = tmp
  
  print(ans)

main()

### FIXED CODE ###

import sys
def main():
  if 'get_ipython' not in globals():  
    # For Subsession
    N,K = map(int, input().split())
    h = []
    for _ in range(N):
      h.append(int(input()))
  else:
    N = 5
    K = 3
    h = [10,15,11,14,12]
    # N = 5
    # K = 3
    # h = [5,7,5,7,7]

  h.sort()  

  ans = (h[K-1] - h[0])
  
  max_i = len(h)-K+1
  for i in range(1,max_i):
    tmp = (h[i+K-1] - h[i])
    if ans > tmp:
      ans = tmp
    if ans == 0:
      print(ans)
      sys.exit()
  
  print(ans)

main()
while True :
    (H, W) = [int(i) for i in input().split()]
 
    if H == W == 0:
        break
 
??????print('#' * W)
    for i in range(H - 2) :
        print('#' + ('.' * (W - 2)) + '#')
    print('#' * W)

### FIXED CODE ###

while True:
  ( H, W) = [ int(i) for i in input().split()]
  if H == W == 0:
    break
  
  for h in range( H):
    for w in range( W):
      if h == 0 or h == H-1:
        print( '#', end='')
      elif w == 0 or w == W-1:
        pass
        print( '#', end='')
      else:
        print( '.', end='')
    print()
  print()
n = int(input())
arr = list(map(int,input().split()))
ans = 0
for i in range(0,len(arr)+1,2):
    if arr[i] % 2 != 0:
        ans += 1
print(ans)

### FIXED CODE ###

n = int(input())
arr = list(map(int,input().split()))
ans = 0
for i in range(0,len(arr)+(n%2),2):
    if arr[i] % 2 != 0:
        ans += 1
print(ans)
from sys import stdin
s1, s2, s3 = [x for x in list(stdin.readline())]


### FIXED CODE ###

print(input().count("1"))
import sys

# input処理を高速化する
input = sys.stdin.readline

def main():
    N = int(input())
    p = list(map(float, input().split()))

    # dp[j] := 表が j 枚となる確率
    # dp[j] = dp[j-1]*p[i] + dp[j]*(1-p[i]) ただしdp[j]が重複していることに注意
    dp = [0.0] * (N+1)
    # 初期条件
    dp[0]= 1.0

    for i in range(N):
        p_tail = 1 - p[i]
        dp = [dp[j -1] * p[i] + dp[j] * p_tail[i] for j in range(N+1)]

        # 更新前のdpを更新に使う。
        dp_before_update = dp[:]
        for j in range(N+1):
            dp[j] = (dp_before_update[j-1] * lst_p[i]) + (dp_before_update[j] * (1 - lst_p[i]))
    
    ans = sum(dp[(N//2+1):])

    print(ans)

main()

### FIXED CODE ###

import sys

# input処理を高速化する
input = sys.stdin.readline

def main():
    N = int(input())
    lst_p = list(map(float, input().split()))

    # dp[i][j] := 最初の i 枚のコインを投げたときに、表が j 枚となる確率
    # 次のコインが表: dp[i+1][j+1] += dp[i][j]∗p[i]
    # 次のコインが裏: dp[i+1][j] += dp[i][j]∗(1.0−p[i])
    dp = [[0] * (N+1) for i in range(N+1)]

    # 初期条件
    dp[0][0] = 1.0

    for i in range(N):
        for j in range(N):
            dp[i+1][j+1] += dp[i][j] * lst_p[i]
            dp[i+1][j] += dp[i][j] * (1.0 - lst_p[i])
    
    ans = 0
    for i in range((N+1)//2, N+1):
        ans += dp[N][i]

    print(ans)

main()
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import bisect
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))

N, K = LI()
A = LI()

A.sort()
B = copy.deepcopy(A)
B.reverse()
ans = 0

def ncr(n,r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

counts = collections.Counter(B)
# max
maxs = 0
tmp_n = N
for k, v in sorted(counts.items(), key=lambda x: -x[0]):
    tmp_n -= v
    for c in range(1,min(v, K) + 1):
        tmp_k = K - c
        if tmp_k <= 0 or tmp_n <= 0:
            pass
        else:
            ans += k * ncr(v, c) * ncr(tmp_n, tmp_k)

print(ans, "max")
# min
tmp_n = N
for k, v in sorted(counts.items()):
    tmp_n -= v
    for c in range(1,min(v, K) + 1):
        tmp_k = K - c
        if tmp_k <= 0 or tmp_n <= 0:
            pass
        else:
            ans -= k * ncr(v, c) * ncr(tmp_n, tmp_k)

print(ans % mod)


### FIXED CODE ###

# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import bisect
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000
def LI(): return list(map(int, sys.stdin.readline().split()))

P = 10**9 + 7
N = 10000

n_ = 10**5 + 3

fun = [1 for i in range(n_+1)]
for i in range(1, n_ + 1):
    fun[i] = fun[i-1] * i % mod

rev = [1 for i in range(n_+1)]
rev[n_] = pow(fun[n_], mod-2, mod)
for i in range(n_-1,0,-1):
    rev[i] = rev[i+1]*(i+1) % mod

def nCr(n,r):
    if n <= 0 or r < 0 or r> n:return 0
    return fun[n]*rev[r]%mod*rev[n-r]%mod

N, K = LI()
A = LI()

A.sort()
B = copy.deepcopy(A)
B.reverse()
ans = 0

# max
tmp_n = N
tmp_k = K - 1
for b in B:
    tmp_n -= 1
    if tmp_n < tmp_k:
        break
    ans = (ans + b * nCr(tmp_n, tmp_k))%mod

# print(ans, "max")
# min
tmp_n = N
tmp_k = K - 1
for a in A:
    tmp_n -= 1
    if tmp_n < tmp_k:
        break
    ans = (ans - a * nCr(tmp_n, tmp_k))%mod

print(ans)
### 動的計画法のテーブルを用意
# dp(n) は頂点nを始点として時の最大有効パスの長さ

def get_inputs():
    N, M = map(int, input().split())

    # グラフgを初期化
    g = [[] for _ in range(N)]

    # 辺情報を読み込みgに追加
    for _ in range(M):
        x, y = map(lambda c: int(c) - 1, input().split())
        g[x].append(y)

    return N, M, g


def getlp(x, depth):
    global dp, g

    if depth >= MAX_DEPTH:
        return -1
    elif dp[x] != -1:
        return dp[x]
    elif len(g[x]) == 0:
        dp[x] = 0
        return dp[x]
    else:
        mxp = 0
        for y in g[x]:
            yp = getlp(y, depth + 1)
            if yp == -1:
                return -1
            elif yp > mxp:
                mxp = yp
        dp[x] = mxp + 1
        return dp[x]


N, M, g = get_inputs()
MAX_DEPTH = 1000

dp = [-1] * N
nodes = list(range(N))
ans = 0

while len(nodes) > 0:
    tmp_nodes = []
    for x in range(N):
        if dp[x] == -1:
            t = getlp(x, 0)
            if t == -1:
                tmp_nodes.append(x)
            else:
                ans = max(ans, t)
        else:
            ans = max(ans, dp[x])

    nodes = list(tmp_nodes)

print(ans)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**5)

def get_inputs():
    N, M = map(int, input().split())
    
    # グラフgを初期化
    g = [[] for _ in range(N)]
    
    # 辺情報を読み込みgに追加
    for _ in range(M):
        x, y = map(lambda c: int(c) - 1, input().split())
        g[x].append(y)
    
    return N, M, g


def getlp(x):
    global dp, g
    
    if dp[x] != -1:
        return dp[x]
    elif len(g[x]) == 0:
        dp[x] = 0
        return dp[x]
    else:
        dp[x] = max([getlp(y) for y in g[x]]) + 1
        return dp[x]


N, M, g = get_inputs()

dp = [-1] * N
ans = 0
for x in range(N):
    ans = max(ans, getlp(x))

print(ans)
#N is numbers of BAITO, M is limit of days
N,M=map(int,input().split())

i=0
inp ={}
while i<N:
  readTime,inCome=map(int,input().split())
  if readTime in inp:
    inp[readTime].append(inCome)
  else:
    inp[readTime]=[inCome]
  
  i=i+1

#print(inp)  

result=0
pool=[]
i=1
while i<=M:
  if i in inp:
	  pool=pool+inp[i]
  #print(i,pool)
  
  if len(pool)>0:
    result=result+max(pool)
    pool.remove(max(pool))
    #print(pool)
  
  i=i+1
 
print(result)

### FIXED CODE ###

A,B =map(int,input().split())
print(max([A+B,A-B,A*B]))
A=int(input())
B=int(input())
if (A>=0 and A<=100) and (B>=0 and B<=100):
  print("A X B =",A*B)
else:
  print (NA)

### FIXED CODE ###

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