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

import sys
n, k = map(int, input().split())
hp_list = list(map(int, input().split()))
hp_list.sort(reverse=True)

if k >= len(hp_list):
    print(0)
    sys.exit()

for del_num in range(k):
    del hp_list[0]
print(sum(hp_list))


### FIXED CODE ###

import sys
n, k = map(int, input().split())
hp_list = list(map(int, input().split()))
hp_list.sort(reverse=True)

if k >= len(hp_list):
    print(0)
    sys.exit()

hp_list = hp_list[k:]
print(sum(hp_list))
### BUGGY CODE ###

def calc(N, adj, ignore, dp, prevs):
    s, t = ignore
    for i in range(prevs+1):
        dp[i] = 0.0
    for i in range(prevs, -1, -1):
        n = len(adj[i])
        if i == s:
            n -= 1
            if n == 0:
                return float("Inf")
        for nxt in adj[i]:
            if i == s and nxt == t:
                continue
            dp[i] += (dp[nxt] + 1) / n
    return dp[0]


def main():
    N, M = map(int, input().split())
    adj = [set() for _ in range(N)]
    x = [(-1, -1)]
    for _ in range(M):
        s, t = map(int, input().split())
        adj[s-1].add(t-1)
        x.append((s-1, t-1))
    x.sort(reverse=True)
    ans = float("Inf")
    dp = [0.0] * (N)
    dp[N-1] = 0.0
    prevs = N - 1
    for ignore in x:
        tmp = calc(N, adj, ignore, dp, prevs)
        ans = min(ans, tmp)
        prevs = ignore[0]
    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

def calc(N, adj, dp, ignore):
    s, t = ignore
    for i in range(N-1, -1, -1):
        dp[i] = 0.0
        n = len(adj[i])
        if i == s:
            n -= 1
        for nxt in adj[i]:
            if i == s and nxt == t:
                continue
            dp[i] += (dp[nxt] + 1) / n
    return dp[0]


def main():
    N, M = map(int, input().split())
    adj = [set() for _ in range(N)]
    for _ in range(M):
        s, t = map(int, input().split())
        adj[s-1].add(t-1)
    dp1 = [0.0] * N
    ans = calc(N, adj, dp1, (-1, -1))
    dp2 = [0.0] * N
    for i in range(N-1, -1, -1):
        if len(adj[i]) <= 1:
            continue
        j = i
        mx = -1
        for nxt in adj[i]:
            if dp1[nxt] > mx:
                j = nxt
                mx = dp1[nxt]
        tmp = calc(N, adj, dp2, (i, j))
        ans = min(ans, tmp)
    print(ans)


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

#https://atcoder.jp/contests/abc152/tasks/abc152_c
# -*- coding: utf-8 -*-
N = int(input())
P = input().split()
T = []
L =0

T.insert(0,int(P[0]))
P[0] = int(P[0])
for i in  range(1,len(P)):
  P[i] = int(P[i])
  if min(T)>=P[i]:
    L =+ 1
    T.append(P[i])
print(len(T))

### FIXED CODE ###

#https://atcoder.jp/contests/abc152/tasks/abc152_c
# -*- coding: utf-8 -*-
N = int(input())
P = input().split()
T = []
L =0
T.insert(0,int(P[0]))
P[0] = int(P[0])
for i in  range(1,len(P)):
  P[i] = int(P[i])
  if T[-1]>=P[i]:
    L =+ 1
    if T[-1]>P[i]:
      T.append(P[i])
print(len(T))
### BUGGY CODE ###

from collections import deque
N,X,Y = map(int,input().split())
edge = [[] for _ in range(N)]
for i in range(N):
    if i == 0:
        edge[i].append(i+1)
    elif i == N-1:
        edge[i].append(i-1)
    else:
        edge[i].append(i-1)
        edge[i].append(i+1)
edge[X-1].append(Y-1)
edge[Y-1].append(X-1)

ans = [0]*(N-1)

for i in range(N):
    visited = [0]*N
    dist = [0]*N
    q = deque([i])#i番目のノードを根とする探索
    visited[i] = 1
    while q:
        now = q.popleft()
        for connection in edge[now]:
            if visited[connection]:
                dist[connection] = min(dist[connection],dist[now]+1)
            else:
                visited[connection] = 1
                dist[connection] = dist[now] + 1
                q.append(connection)
    for d in dist:
        if d == 0:
            continue
        ans[d-1] += 1
ans = list(map(lambda x: x//2,ans))
print(*ans,sep="\n")

### FIXED CODE ###

from collections import deque
import sys
input = sys.stdin.readline

def main():
    N,X,Y = map(int,input().split())
    edge = [[] for _ in range(N)]
    for i in range(N):
        if i == 0:
            edge[i].append(i+1)
        elif i == N-1:
            edge[i].append(i-1)
        else:
            edge[i].append(i-1)
            edge[i].append(i+1)
    edge[X-1].append(Y-1)
    edge[Y-1].append(X-1)
    
    ans = [0]*(N-1)
    
    for i in range(N):
        visited = [0]*N
        dist = [0]*N
        q = deque([i])#i番目のノードを根とする探索
        visited[i] = 1
        while q:
            now = q.popleft()
            for connection in edge[now]:
                if visited[connection]:
                    dist[connection] = min(dist[connection],dist[now]+1)
                else:
                    visited[connection] = 1
                    dist[connection] = dist[now] + 1
                    q.append(connection)
        for d in dist:
            if d == 0:
                continue
            ans[d-1] += 1
    ans = list(map(lambda x: x//2,ans))
    print(*ans,sep="\n")
if __name__ == '__main__':
    main()
### BUGGY CODE ###

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

mod=998244353

def modinv(a, mod):
    return pow(a, mod-2, mod)

def mod_comb_count(n, r, mod):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

ans=0

for i in range(k+1):
    ans += mod_comb_count(n-1, i, mod) * m * ((m-1)**(n-1-i)) %mod
print(ans%mod)


### FIXED CODE ###

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

mod=998244353
ans=0
c=1
for i in range(k+1):
    ans+=c*m*pow(m-1, n-1-i, mod)
    ans%=mod
    c*=(n-i-1)*pow(i+1, mod-2, mod)
    c%=mod
print(ans%mod)
### BUGGY CODE ###

#2
s = list(input())
l = len(s)
cnt = 0

i = 0
while i == 0:
    for j in range(l-1):
        if s[j] =="B" and s[j+1] == "W":
            cnt += 1
            s[j],s[j+1] = s[j+1],s[j]
            i = 0
            break
        i = 1
print(cnt)

### FIXED CODE ###

s=input()

ans=0
b_cnt=0
for i in range(len(s)):
  if s[i]=='B':
    b_cnt+=1
  else:
    ans+=b_cnt

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

R, G, B, N = map(int,input().split())

ans = 0
for i in range(N//R+1):
    for j in range(N//G+1):
        if N - R * i - G * j < 0:
            break
        if  N -R*i -G*j == 0:
            ans += 1
        elif N -R*i -G*j > 0 and (N -R*i -G*j) % B == 0:
            ans += 1

print(ans)

### FIXED CODE ###

R, G, B, N = map(int,input().split())

ans = 0
for i in range(N//R+1):
    for j in range((N- R*i)//G+1):
        if (N -R*i -G*j) % B == 0:
            ans += 1

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

input = raw_input


def answer():
    n, m, v, p = map(int, input().split(" "))
    nums = sorted(map(int, input().split(" ")), reverse=True)

    num_last = nums[p-1]

    nokori_sum = sum(nums[p-1:n])

    out = p
    count = 0
    if v > p:
        for i in range(p, n):
            x = nums[i]
            if x + m < num_last:
                break

            #nokori_yoyuu = ( (x + m) * (n-p+1- 1) ) - (nokori_sum-x)
            nokori_yoyuu = 0
            for j in range(p-1, n):
                if j == i:
                    continue
                x2 = nums[j]
                cur_yoyuu = max(0, min(x+m-x2, m))
                nokori_yoyuu += cur_yoyuu
            cost = (v-p) * m
            if cost > nokori_yoyuu:
                break

            count += 1

        out += count

    else:
        for x in nums[p:]:
            if x + m < num_last:
                break
            count += 1
        out += count

    print(out)

answer()

### FIXED CODE ###

input = raw_input


def answer():
    n, m, v, p = map(int, input().split(" "))
    nums = sorted(map(int, input().split(" ")), reverse=True)

    num_last = nums[p-1]

    nokori_sum = sum(nums[p-1:n])

    out = p
    count = 0
    if v > p:
        cumsum = {}
        cur = 0
        
        cur = 0
        for i in range(p-1, n):
            x = nums[i]
            cur += x
            cumsum[i] = cur

        for i in range(p, n):
            x = nums[i]
            if x + m < num_last:
                break

            #nokori_yoyuu = ( (x + m) * (n-p+1- 1) ) - (nokori_sum-x)
            #nokori_yoyuu = 0
            #for j in range(p-1, n):
            #    if j == i:
            #        continue
            #    x2 = nums[j]
            #    cur_yoyuu = max(0, min(x+m-x2, m))
            #    nokori_yoyuu += cur_yoyuu

            area1 = (x+m) * (i-p+1) - cumsum[i-1]
            #print("n", n, "i", i, "m", m)
            area2 = (n - i - 1) * m
            #print(area1, area2, nokori_yoyuu)

            nokori_yoyuu = area1 + area2

            cost = (v-p) * m
            if cost > nokori_yoyuu:
                break

            count += 1

        out += count

    else:
        for x in nums[p:]:
            if x + m < num_last:
                break
            count += 1
        out += count

    print(out)

answer()
### BUGGY CODE ###

from math import ceil, sqrt, floor, log10

N = int(input())

for i in range(ceil(sqrt(N)), N + 1):
    if N % i == 0:
        print(floor(log10(i)) + 1)
        break


### FIXED CODE ###

from math import floor, sqrt, log10

N = int(input())

for i in range(floor(sqrt(N)), 0, -1):
    if N % i == 0:
        print(floor(log10(N // i)) + 1)
        break
### BUGGY CODE ###

import sys
def i_map(): return map(int, input().split())
sys.setrecursionlimit(10 ** 7)

def dfs(current, parent, edges, ans_list):
    for child in edges[current]:
        if child == parent:
            continue
        ans_list[child] += ans_list[current]
        dfs(child, current, edges, ans_list)

def main():
    n, q = i_map()

    edges = [[] for _ in range(n)]
    for i in range(n-1):
        a, b = i_map()
        edges[a-1].append(b-1)
        edges[b-1].append(a-1)

    ans_list = [0] * n
    for i in range(q):
        p, x = i_map()
        ans_list[p-1] += x

    dfs(0, -1, edges, ans_list)

    print(*ans_list)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys, re
from math import ceil, floor, sqrt, pi#, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_rpw_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 7)
INF = float('inf')
MOD = 10 ** 9 + 7

def dfs(current, parent, edges, ans_list):
    for child in edges[current]:
        if child == parent:
            continue
        ans_list[child] += ans_list[current]
        dfs(child, current, edges, ans_list)

def main():
    n, q = i_map()

    edges = [[] for _ in range(n)]
    for i in range(n-1):
        a, b = i_map()
        edges[a-1].append(b-1)
        edges[b-1].append(a-1)

    ans_list = [0] * n
    for i in range(q):
        p, x = i_map()
        ans_list[p-1] += x

    dfs(0, -1, edges, ans_list)

    print(*ans_list)

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

N = int(input())
a = list(input() for i in range(N))
ls = []
ls3 = []
for i in range(N):
  if a[i] not in ls:
    ls.append(a[i])
ls2 = [0 for i in range(len(ls))]
for i in range(len(ls)):
  for j in range(len(a)):
    if ls[i] == a[j]:
      ls2[i] += 1
for i in range(len(ls)):
  if ls2[i] == max(ls2):
    ls3.append(ls[i])
ls3.sort()
for i in range(len(ls3)):
  print(ls3[i])

### FIXED CODE ###

N = int(input())
a = list(input() for i in range(N))
a.sort()
count = 1
max = 0
ls = []
for i in range(N - 1):
  if a[i] == a[i + 1]:
    count += 1
  else:
    if count > max:
      ls = []
      ls.append(a[i])
      max = count
    elif count == max:
      ls.append(a[i])
    count = 1
if count > max:
  ls = []
  ls.append(a[N - 1])
elif count == max:
  ls.append(a[N - 1])
ls.sort()
for i in range(len(ls)):
  print(ls[i])
### BUGGY CODE ###

N, M = map(int, input().split(' '))
H = list(map(int, input().split(' ')))
MICHI = []
for m in range(M):
    MICHI.append(tuple(map(int, input().split(' '))))

# 展望台接続関係マップ
setsuzokumap = [[0 for i in range(N)] for j in range(N)]

for m in MICHI:
    setsuzokumap[m[0] - 1][m[1] - 1] = 1

# print(setsuzokumap)

good_tenboudai = [None] * N

# すべての展望台を調べる
for n in range(N):
    # 未判断の展望台を調べる
    if good_tenboudai[n] is None:
        # すべての接続パターンを調べる
        for m in range(N):
            # 接続あり
            if setsuzokumap[n][m] == 1:
                # 接続先が良い展望台ならば、この展望台は自動的によくない
                if good_tenboudai[m] == 1:
                    good_tenboudai[n] = 0
                else:
                    # 接続先の高さが自分以下だったら接続先は必ずよくない
                    if H[m] <= H[n]:
                        good_tenboudai[m] = 0

                    # 自分の高さが接続先以下だったらよくない
                    if H[n] <= H[m]:
                        good_tenboudai[n] = 0

# 最後まで良くないと判定されなかったのが良いの
for n in range(N):
    if good_tenboudai[n] is None:
        good_tenboudai[n] = 1

print(sum(good_tenboudai))


### FIXED CODE ###

N, M = map(int, input().split(' '))
H = list(map(int, input().split(' ')))
MICHI = []

# 10**5回
for m in range(M):
    MICHI.append(tuple(map(int, input().split(' '))))

# 展望台接続関係マップ
# setsuzokumap = [[0 for i in range(N)] for j in range(N)]
setsuzokumap_d = {}
setsuzokumap_me = [[] for j in range(N)]

# 10**5回
for m in MICHI:
    # setsuzokumap[m[0] - 1][m[1] - 1] = 1
    # k = (m[0] - 1, m[1] - 1)

    setsuzokumap_me[m[0] - 1].append(m[1] - 1)
    setsuzokumap_me[m[1] - 1].append(m[0] - 1)

    # setsuzokumap_d.update({k: 1})

# print(setsuzokumap_d)

good_tenboudai = [None] * N

# すべての展望台を調べる
# 10**5
for n in range(N):
    # 未判断の展望台を調べる
    if good_tenboudai[n] is None:
        # すべての接続パターンを調べる
        if setsuzokumap_me[n]:
            # 最大10**5
            for setsuzokusaki in setsuzokumap_me[n]:

                m = setsuzokusaki

                # 接続先が良い展望台ならば、この展望台は自動的によくない
                if good_tenboudai[m] == 1:
                    good_tenboudai[n] = 0
                else:
                    # 接続先の高さが自分以下だったら接続先は必ずよくない
                    if H[m] <= H[n]:
                        good_tenboudai[m] = 0

                    # 自分の高さが接続先以下だったらよくない
                    if H[n] <= H[m]:
                        good_tenboudai[n] = 0


# 最後まで良くないと判定されなかったのが良いの
# 10**5
for n in range(N):
    if good_tenboudai[n] is None:
        good_tenboudai[n] = 1

# print(good_tenboudai)
print(sum(good_tenboudai))
### BUGGY CODE ###

n = int(input())
a_list = list(map(int,input().split()))
ans = []
a = 0
for i in range(n):
    if i%2 == 0:
        a += a_list[i]/2
    else:
        a -= a_list[i]/2
ans.append(2*a)
point = a
for i in range(n):
    point = a_list[i]-point
    ans.append(point*2)
out = ""
for num in ans[:-1]:
    out += str(int(num)) + " "
print(out[:-1])

### FIXED CODE ###

def main():
    n = int(input())
    a_list = list(map(int,input().split()))
    a = 0
    end = 0
    for i in range(n):
        if i%2 == 0:
            a += a_list[i]*0.5
        else:
            a -= a_list[i]*0.5

    out = str(int(a*2))
    point = a
    for i in range(n-1):
        point = a_list[i]-point
        out += " "+str(int(point*2))
    print(out)

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

s = input()
k = int(input()) -1

array = set()
for i in range(len(s)):
  for j in range(i+1,len(s)+1):
    array.add(s[i:j])
    
array = sorted(array)

print(array[k])

### FIXED CODE ###

s = input()
k = int(input())

s_sorted = sorted(s)
array = set()

n = len(s)
for i in range(n):
  for j in range(n):
    if s_sorted[i] == s[j]:
      for l in range(k):
        if l+j >= n:
          break
        
        array.add(s[j:l+j+1])
      
  if len(array) >= k:
    break
    
array = sorted(array)
print(array[k-1])
### BUGGY CODE ###

from collections import defaultdict
n, *D  = [list(map(int, s.split())) for s in open(0)]
D = D[0]
dic = defaultdict(int)
for d in D:
    dic[d] += 1

for d in D:
    dic[d] -= 1
    comb = 0
    for i in dic.values():
        if i >= 2:
            comb += i * (i - 1) / 2
    dic[d] += 1
    print(int(comb))

### FIXED CODE ###

from collections import defaultdict
n, *D  = [list(map(int, s.split())) for s in open(0)]
D = D[0]
dic = defaultdict(int)
for i in D:
    dic[i] += 1

total_comb = 0
for j in dic:
    if dic[j] >= 2:
        total_comb += dic[j] * (dic[j] - 1) / 2
for k in D:
    if dic[k] >= 2:
        print(int(total_comb - dic[k] + 1))
    else:
        print(int(total_comb))
### BUGGY CODE ###

# -*- coding: utf-8 -*-
"""
D - Knapsack 1
https://atcoder.jp/contests/dp/tasks/dp_d

"""
import sys


def solve(N, W, items):
    ans = {0: 0}
    for w, v in items:
        u = dict()
        for x, y in ans.items():
            if x+w <= W and ans.get(x+w, 0) < y+v:
                u[x+w] = y+v
        ans.update(u)
    return max([v for v in ans.values()])


def main(args):
    N, W = map(int, input().split())
    items = [[int(i) for i in input().split()] for _ in range(N)]
    ans = solve(N, W, items)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
D - Knapsack 1
https://atcoder.jp/contests/dp/tasks/dp_d

"""
import sys


def solve(N, W, items):
    ans = {0: 0}
    for w, v in items:
        u = dict()
        for x, y in ans.items():
            if x+w <= W and ans.get(x+w, 0) < y+v:
                u[x+w] = y+v
        ans.update(u)
    return max([v for v in ans.values()])


def main(args):
    N, W = map(int, input().split())
    items = [[int(i) for i in input().split()] for _ in range(N)]
    ans = solve(N, W, items)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])
### BUGGY CODE ###

import sys
import numpy as np
import numba
from numba import njit
i8 = numba.int64

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

@njit((i8[:], i8, i8), cache=True)
def test(A, keta, n):
    # 10^keta の位を n にできるか
    MOD = 10**(keta + 1)
    I = [(n * 10**keta, (n + 1) * 10**keta)]  # [l, r)
    for x in A:
        if I[0][0] == 0:
            return True
        newI = I.copy()
        x %= MOD
        for l, r in I:
            l, r = l + MOD - x, r + MOD - x
            if l >= MOD:
                l, r = l - MOD, r - MOD
            if r <= MOD:
                newI.append((l, r))
            else:
                newI.append((l, MOD))
                newI.append((0, r - MOD))
        I = newI
        I.sort(key=lambda x: x[1])
        newI = [(0, 0)] * 0
        for x, y in I:
            while newI and newI[-1][1] >= x:  # つなぐ
                x, y = min(x, newI[-1][0]), y
                newI.pop()
            newI.append((x, y))
        I = newI
    return I[0][0] == 0

def main(A):
    N = len(A)
    ans = 0
    for keta in range(18):
        for x in range(9, 0, -1):
            if test(A, keta, x):
                ans += x
                break
    return ans

A = np.array(read().split(), np.int64)[1:]
print(main(A))

### FIXED CODE ###

import sys
import numpy as np
import numba
from numba import njit
i8 = numba.int64

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

@njit((i8[:], i8), cache=True)
def solve(A, keta):
    # 10^keta の位を n にできるか
    MOD = 10**(keta + 1)
    B = 10**keta
    nums = [0]
    for x in A:
        x %= MOD
        n = len(nums)
        for i in range(n):
            s = nums[i] + x
            if s >= MOD:
                s -= MOD
            nums.append(s)
        nums.sort()
        # x, y, z とあって、x + z < B ならば、y は捨ててよい
        tmp = []
        for x in nums:
            while len(tmp) >= 2 and tmp[-2] + B > x:
                tmp.pop()
            tmp.append(x)
        nums = tmp
    return nums[-1] // B

def main(A):
    N = len(A)
    ans = 0
    for keta in range(18):
        x = solve(A, keta)
        ans += x
    return ans

A = np.array(read().split(), np.int64)[1:]
np.random.shuffle(A)
print(main(A))
### BUGGY CODE ###

import sys
import math
#import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split())) # applies to numbers only
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N = ri()
X = rl()
MOD = 10 ** 9 + 7
limit = math.factorial(N-1)
last = X[-1]
X = [last - x for x in X] #最後までの距離
answer = 0
for i in range(1, N):
    answer += X[i-1] * limit // i
    answer %= MOD

print(answer)



### FIXED CODE ###

import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

def cumprod(arr, MOD):
    L = len(arr); Lsq = int(L**.5+1)
    arr = np.resize(arr, Lsq**2).reshape(Lsq, Lsq)
    for n in range(1, Lsq):
        arr[:, n] *= arr[:, n-1]; arr[:, n] %= MOD
    for n in range(1, Lsq):
        arr[n] *= arr[n-1, -1]; arr[n] %= MOD
    return arr.ravel()[:L]

def make_fact(U, MOD):
    x = np.arange(U, dtype=np.int64); x[0] = 1
    fact = cumprod(x, MOD)
    x = np.arange(U, 0, -1, dtype=np.int64); x[0] = pow(int(fact[-1]), MOD-2, MOD)
    fact_inv = cumprod(x, MOD)[::-1]
    return fact, fact_inv

MOD = 10 ** 9 + 7
U = 10 ** 5 + 10 # 階乗テーブルの上限
fact, fact_inv = make_fact(U, MOD)
N = ir()
X = np.array(lr())

inv = np.zeros(U, np.int64)
inv[1:] = fact_inv[1:] * fact[:-1] % MOD
coef = inv[1:N].cumsum() % MOD
answer = (np.diff(X) * coef % MOD).sum() % MOD
answer *= fact[N-1]
print(answer % MOD)
# 35
### BUGGY CODE ###

from itertools import combinations
MOD = 1000000007
n=int(input())
a=list(map(int,input().split()))
sum=0
for x,y in combinations(a,2):
   sum+= x*y
print(sum%MOD)

### FIXED CODE ###

mod = 10**9 + 7
n=int(input())
s=list(map(int,input().split()))
s2=sum(map(lambda x: x ** 2,s))
ans=(((sum(s))**2)-(s2))//2%mod
print(ans)
### BUGGY CODE ###

def main():
    N,K = map( int, input().split())
    P = list(input().split())
    max_ex = 0
    
    for i in range(N-K+1):
        sum_ex = sum(1.0/float(P[j])*float(P[j])*(float(P[j])+1)/2 for j in range(i,i+K))
        if sum_ex>max_ex:
            max_ex = sum_ex
    print(max_ex)
        

    
if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	D
# CreatedDate:  2020-07-29 16:20:16 +0900
# LastModified: 2020-07-29 16:30:22 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd
from itertools import accumulate


def main():
    n, k = map(int, input().split())
    p = list(map(int, input().split()))
    s = [(x+1)/2 for x in p]
#    print(s)
    s = list(accumulate(s))
    s.insert(0, 0)
    ans = 0
#    print(s)
    for i in range(n-k+1):
        ans = max(ans, s[i+k]-s[i])
    print(ans)



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

n = int(input())
s = input()
res = []
for i in range(1,n-1):
    l1 = s[:i-1]
    l2 = s[i+1:]
    res.append(l1.count("W")+l2.count("E"))
print(min(res))

### FIXED CODE ###

n = int(input())
s = input()
cnt = s.count("E")
res = cnt
for i in s:
    if i=="E":
        cnt-=1
    else:
        cnt+=1
    res=min(res,cnt)
print(res)