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

import numpy as np
import sys
N, M = map(int,input().split())
X = list(map(int,input().split()))
X.sort()

X_list = list(np.diff(X))

if M-N < 1:
    print(0)
    sys.exit()

for _ in range(N-1):
    X_list.remove(max(X_list))
    
print(sum(X_list))

### FIXED CODE ###

import numpy as np
import sys
N, M = map(int,input().split())
X = list(map(int,input().split()))
X.sort()

X_list = list(np.diff(X))

if M-N < 1:
    print(0)
    sys.exit()

X_list.sort(reverse=True)
print(sum(X_list[N-1:]))
### BUGGY CODE ###

import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  k=[0]*60
  n=I()
  l=LI()

  for x in l:
    _a=bin(x)[2:]
    a=_a.zfill(60)

    for i,y in enumerate(a):
      if y=='1':
        k[59-i]+=1

  ans=0
  for i,x in enumerate(k):
    ans+=(n-x)*x*(2**i)
    ans%=mod

  return ans%mod

# main()
print(main())


### FIXED CODE ###

import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  k=[0]*60
  n=I()
  l=LI()

  for x in l:
    _a=bin(x)[2:]
    a=_a.zfill(60)

    for i,y in enumerate(a):
      if y=='1':
        k[59-i]+=1

  ans=0
  for i,x in enumerate(k):
    ans+=(n-x)*x*(2**i)
    ans%=mod

  return ans%mod

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

N, Q = [int(x) for x in input().split()]
G = [1] * N

index={}
for i,s in enumerate(input().strip()):
    index.setdefault(s, []).append(i)
import sys
input = sys.stdin.readline

for _ in range(Q):
    t, _, d = input()[:3]
    if t not in index:
        continue

    if d == 'L':
        for i in index[t]:
            if i > 0:
                G[i-1]+= G[i]
            G[i] = 0

    else:
        for i in index[t]:
            if i < N - 1:
                G[i+1] += G[i]
            G[i] = 0
print(sum(G)) 


### FIXED CODE ###

#!/usr/bin/python3
N, Q = [int(x) for x in input().split()]
S = input()

qs = []
for _ in range(Q):
    t, d = [x for x in input().split()]
    #print(t, d)
    qs.append((t,-1 if d == 'L' else 1))

memo = [None] * N
memo.append(N)

def move(i):
    org = i
    if memo[i]:
        return memo[i]
    for t, d in qs:
        if S[i] == t:
            i+=d
        if i == -1:
            break
        elif i == N:
            break
    memo[org] = i
    return i

def search_right(lo, hi, x):
    while lo < hi:
        mid = lo + (hi - lo) // 2
        if x < move(mid):
            hi = mid 
        else: # e <= t
            lo = mid +1
    return lo

def search_left(lo, hi, x):
    while lo < hi:
        mid = lo + (hi - lo) // 2
        if move(mid) < x:
            lo = mid +1
        else: # e <= t
            hi = mid
    return lo


#l = search(0, N-1, -1)
#assert move(l) == 2, "%d" % move(l)
#print("search(-1)=", l)

l = search_right(0, N, -1)
r = search_left(0, N, N)

if 1==0:
    print(S)
    for t, d in qs:
        print(t, {-1:'L', 1:'R'}[d])
    m = [move(i) for i in range(N+1)]
    print(" ".join("%2d" % i for i in range(N+1)))
    print(" ".join("%+d" % x for x in m))
    print(" ".join(" *" if l == i else "  " for i in range(N+1)))
    print(" ".join(" *" if r == i else "  " for i in range(N+1)))

print(r-l)
### BUGGY CODE ###

S = input()
lst = ["dreamer", "dream", "eraser", "erase"]
lst = [ "".join(list(reversed(k))) for k in lst]
S = "".join(list(reversed(S)))

i  = 0
while i < len(S):
    found = False
    for k in lst:
        try:
            if S[i:].index(k) == 0:
                found = True
                i += len(k)
                break
        except:
            continue

    if not found:
        print("NO")
        exit(0)
print("YES")


### FIXED CODE ###

S = input()
lst = ["dreamer", "dream", "eraser", "erase"]
lst = [ "".join(list(reversed(k))) for k in lst]
S = "".join(list(reversed(S)))

i  = 0
while i < len(S):
    found = False
    for k in lst:
        try:
            if S[i:].index(k) == 0:
                found = True
                i += len(k)
                break
        except:
            continue

    if not found:
        print("NO")
        exit(0)
print("YES")
### BUGGY CODE ###

N = int(input())
A = [0] * N
A = list(map(int,input().split()))

ans = 0
mod = 10**9+7
# for i in range(N-1):
#     for j in range(i+1,N):
#         ans += (A[i]%mod) * (A[j]%mod)
#         ans %= mod

A = list(map(lambda x: x %mod,A))
for i in range(N-1):
    for j in range(i+1,N):
        ans += A[i] * A[j]
        ans %= mod
print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
B = [0] * (N+1)

# 累積和を使う
for i in range(1,N+1):
    B[i] = A[i-1]+B[i-1]
# 累積和の配列完成
# print(B) 

ans = 0
MOD = 10**9+7
for i in range(N):
    ans += A[i] * (B[N] - B[i+1])
    ans %= MOD
print(ans)
### BUGGY CODE ###

#入力
h,w=map(int,input().split())
ch,cw=map(int,input().split())
dh,dw=map(int,input().split())
s=[]
for i in range(h):
  s_=list(input())
  s.append(s_)
#幅優先探索
from collections import deque
q=deque([[ch-1,cw-1]])
used=[[float("INF")]*w for i in range(h)]
used[ch-1][cw-1]=0
while len(q)>0:
  y,x=q.popleft()
  X=[[-1,0],[1,0],[0,1],[0,-1]]
  for dy,dx in X:
    nx=x+dx
    ny=y+dy
    if nx>=0 and nx<w and ny>=0 and ny<h and s[ny][nx]==".":
      if used[ny][nx]>used[y][x]:
        used[ny][nx]=used[y][x]
        q.appendleft([ny,nx])
  Y=[-2,-1,0,1,2]
  for dx in Y:
    for dy in Y:
      if not(dx==0 and dy==0):
        if [dy,dx] not in X:
          nx=x+dx
          ny=y+dy
          if nx>=0 and nx<w and ny>=0 and ny<h and s[ny][nx]==".":
            if used[ny][nx]>used[y][x]:
              used[ny][nx]=used[y][x]+1
              q.append([ny,nx])

if used[dh-1][dw-1]==float("INF"):
  print(-1)
else:
  print(used[dh-1][dw-1])

      
      
      
    
  
  


### FIXED CODE ###

#入力
h,w=map(int,input().split())
ch,cw=map(int,input().split())
dh,dw=map(int,input().split())
from sys import stdin
s=[stdin.readline() for i in range(h)]

#for i in range(h):
#  s_=list(input())
#  s.append(s_)
#幅優先探索
from collections import deque
q=deque([(ch-1,cw-1)])
used=[[float("INF")]*w for i in range(h)]
used[ch-1][cw-1]=0
X=((-1,0),(1,0),(0,1),(0,-1))
Y=((-2,-2),(-2,-1),(-2,0),(-2,1),(-2,2),(-1,-2),(-1,-1),(-1,1),(-1,2),(0,-2),(0,1),(0,2),(1,-2),(1,-1),(1,1),(1,2),(2,-2),(2,-1),(2,0),(2,1),(2,2))
while len(q)>0:
  y,x=q.popleft()
  for dy,dx in X:
    nx=x+dx
    ny=y+dy
    if nx>=0 and nx<w and ny>=0 and ny<h and s[ny][nx]==".":
      if used[ny][nx]>used[y][x]:
        used[ny][nx]=used[y][x]
        q.appendleft((ny,nx))
  for dy,dx in Y:
    nx=x+dx
    ny=y+dy
    if nx>=0 and nx<w and ny>=0 and ny<h and s[ny][nx]==".":
      if used[ny][nx]>used[y][x]:
        used[ny][nx]=used[y][x]+1
        q.append((ny,nx))

if used[dh-1][dw-1]==float("INF"):
  print(-1)
else:
  print(used[dh-1][dw-1])
### BUGGY CODE ###

import itertools

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

lis=[]
for i in range(q):
    lis.append(list(map(int,input().split())))

Alist=[]

for l in itertools.combinations(range(1,n+m),n):
    ll=list(l)
    a=[]
    for i in range(n):
        a.append(ll[i]-i)
    Alist.append(a)

slist=[]
for i in range(len(Alist)):
    s=0
    for j in range(q):
        aj=lis[j][0]
        bj=lis[j][1]
        cj=lis[j][2]
        dj=lis[j][3]
        if Alist[i][bj-1]-Alist[i][aj-1]==cj:
            s+=dj
    slist.append(s)

print(max(slist))

### FIXED CODE ###

import itertools

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

lis=[]
for i in range(q):
    lis.append(list(map(int,input().split())))

M=0
for l in map(list,itertools.combinations(range(1,n+m),n)):
    s=0
    for j in range(q):
        aj=lis[j][0]
        bj=lis[j][1]
        cj=lis[j][2]
        dj=lis[j][3]
        if l[bj-1]-bj-l[aj-1]+aj==cj:
            s+=dj
    M=max(M,s)
print(M)
### BUGGY CODE ###

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

dp = [[0] + [1e20] * (H) for _ in range(N)]

for i in range(N):
    A, B = map(int, (input().split()))
    for j in range(1, H + 1):
        dp[i][j] = min(dp[i - 1][j], dp[i][max(j - A, 0)] + B)

print(dp[-1][-1])

### FIXED CODE ###

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

dp = [[0] + [1e20] * (H) for _ in range(N)]

for i in range(N):
    A, B = map(int, (input().split()))
    for j in range(1, H + 1):
        dp[i][j] = min(dp[i - 1][j], dp[i][max(j - A, 0)] + B)

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

def fibonacci(n):
    if n == 0 or n == 1:
        return 1
    return fibonacci(n - 2) + fibonacci(n - 1)

print(fibonacci(int(input())))

### FIXED CODE ###

def fibonacci(f, n):
    if n == 0 or n == 1:
        f[n] = 1
        return f[n]
    if f[n]:
        return f[n]
    f[n] = fibonacci(f, n - 2) + fibonacci(f, n - 1)
    return f[n]

n = int(input())
f = [None for i in range(n + 1)]
print(fibonacci(f, n))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**9)

N, Q = map(int, input().split())
tree = [[] for _ in range(N)]
ans = [0]*N
for _ in range(N-1):
    aa, bb = map(int, input().split())
    tree[aa-1].append(bb - 1)
    tree[bb-1].append(aa - 1)


for _ in range(Q):
    q, x = map(int, input().split())
    ans[q-1] += x

def DFS(x, pre):
    global ans
    for i in tree[x]:
        if i==pre:
            continue

        ans[i] += ans[x]
        DFS(i, x)

    return

DFS(0, -1)
for x in ans:
    print(x)



### FIXED CODE ###

import sys
from collections import deque

sys.setrecursionlimit(10**9)

N, Q = map(int, input().split())
tree = [[] for _ in range(N)]
ans = [0]*N
queue = deque()

for _ in range(N-1):
    aa, bb = map(int, input().split())
    tree[aa-1].append(bb - 1)
    tree[bb-1].append(aa - 1)


for _ in range(Q):
    q, x = map(int, input().split())
    ans[q-1] += x

# def DFS(x, pre):
#     global ans
#     for i in tree[x]:
#         if i==pre:
#             continue
#
#         ans[i] += ans[x]
#         DFS(i, x)
#
#     return
#
# for _ in range(Q):
#     q, x = map(int, input().split())
#     ans[q-1] += x

def DFS(x, pre):
    global ans
    for i in tree[x]:
        if i==pre:
            continue

        ans[i] += ans[x]
        queue.append((i, x))

queue.append((0, -1))
while queue:
    DFS(*queue.pop())

for x in ans:
    print(x)
### BUGGY CODE ###

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

dp=[2000000000 for i in range(n)]
dp[0]=0
for i in range(n):
    
    for j in range(k+1):
        #print(i,j)
        if i+j>=n:
            break
        else:
            dp[i+j]=min(abs(h[i+j]-h[i])+dp[i],dp[i+j])
            #print(dp[i+j])
print(dp[n-1])
#print(dp)
    


### FIXED CODE ###

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

dp=[2000000000 for i in range(n)]
dp[0]=0
for i in range(n):
    
    for j in range(k+1):
        #print(i,j)
        if i+j>=n:
            break
        else:
            dp[i+j]=min(abs(h[i+j]-h[i])+dp[i],dp[i+j])
            #print(dp[i+j])
print(dp[n-1])
#print(dp)
### BUGGY CODE ###

import sys

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

    A = [int(input()) for _ in range(Q)]
#   print(A)

    pt = [K]*(N + 1)
#   print(pt)

    for i in range(Q):
        for n in range(len(pt)):
            pt[n] -= 1
            if n == A[i]:
                pt[n] += 1
#       print("{0}: {1}".format(i, pt[1:]))

#   print(pt)
    for n in range(1, len(pt)):
        if pt[n] > 0:
            print("Yes")
        else:
            print("No")

if __name__ == "__main__":
    main()


### FIXED CODE ###

n,k,q = map(int,input().split())
ans = [0]*n
for i in range(q):
    idx = int(input()) -1
    ans[idx] += 1
for i in ans:
    print('Yes' if q-k<i else 'No')
### BUGGY CODE ###

import numpy as np
from collections import deque
import numba
from numba import jit

H, W = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())
maze = np.array([input() for i in range(H)])

queue = deque()
queue.append((Ch-1, Cw-1, 0))
inf = float("inf")
table = np.array([[inf] * W for i in range(H)])
table[Ch-1][Cw-1] = 0
walk_move = ((-1, 0), (0, -1), (1, 0), (0, 1))
magic_move = []
for i in range(-2, 3):
  for j in range(-2, 3):
    if not i and not j:
      continue
    else:
      magic_move.append([i, j])
@jit
def main():
  while queue:
    x, y, cost = queue.popleft()
    for i,j in walk_move:
      dx = x+i
      dy = y+j
      if 0 <= dx <= H-1 and 0 <= dy <= W-1 and maze[dx][dy] == "." and table[dx][dy] > cost:
        queue.appendleft((dx, dy, cost))
        table[dx][dy] = cost
    for k,l in magic_move:
      dx = x+k
      dy = y+l
      if 0 <= dx <= H-1 and 0 <= dy <= W-1 and maze[dx][dy] == "." and table[dx][dy] > cost+1:
        queue.append((dx, dy, cost+1))
        table[dx][dy] = cost+1
  return table[Dh-1][Dw-1]

ans = main()
if ans == inf:
  print("-1")
else:
  print(int(ans))


### FIXED CODE ###

from collections import deque

H, W = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())
maze = [input() for i in range(H)]

queue = deque()
queue.append((Ch-1, Cw-1, 0))
inf = float("inf")
table = [[inf] * W for i in range(H)]
table[Ch-1][Cw-1] = 0
walk_move = ((-1, 0), (0, -1), (1, 0), (0, 1))
magic_move = []
for i in range(-2, 3):
  for j in range(-2, 3):
    if not i and not j:
      continue
    else:
      magic_move.append([i, j])

while queue:
  x, y, cost = queue.popleft()
  for i,j in walk_move:
    dx = x+i
    dy = y+j
    if 0 <= dx <= H-1 and 0 <= dy <= W-1 and maze[dx][dy] == "." and table[dx][dy] > cost:
      queue.appendleft((dx, dy, cost))
      table[dx][dy] = cost
  for k,l in magic_move:
    dx = x+k
    dy = y+l
    if 0 <= dx <= H-1 and 0 <= dy <= W-1 and maze[dx][dy] == "." and table[dx][dy] > cost+1:
      queue.append((dx, dy, cost+1))
      table[dx][dy] = cost+1

ans = table[Dh-1][Dw-1]
if ans == inf:
  print("-1")
else:
  print(table[Dh-1][Dw-1])
### BUGGY CODE ###

import numpy as np
from numba import njit

n = int(input())


@njit
def f(n):
    cnt = np.zeros(n + 1, np.int32)
    for i in range(1, n + 1):
        cnt[i::i] += 1

    return (cnt * np.arange(n + 1)).sum()


ans = f(n)
print(ans)


### FIXED CODE ###

n = int(input())

ans = 0
for i in range(1, n + 1):
    cnt = n // i
    ub = i * cnt
    ans += (i + ub) * cnt // 2

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

import sys

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    n = II()
    a_s = LI()
    kaizyo = [1]
    kaizyo_append = kaizyo.append
    keta = [0 for i in range(60)]
    ans = 0
    for i in range(60):
        kaizyo_append(kaizyo[i] * 2 % MOD)
    for i in a_s:
        for i, v in enumerate(bin(i)[:1:-1]):
            keta[i] += int(v)
    for i, v in enumerate(keta):
        c = v * (n-v) % MOD
        ans += c * kaizyo[i]
        ans = ans % MOD
        # print(ans, c, kaizyo[i])

    print(ans)
if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

sys.setrecursionlimit(10**7)
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())

def main():
    n = II()
    a_s = LI()
    kaizyo = [1]
    kaizyo_append = kaizyo.append
    keta = [0 for i in range(60)]
    ans = 0
    for i in range(60):
        kaizyo_append(kaizyo[i] * 2 % MOD)
    for i in a_s:
        for j in range(60):
            v, i = i % 2, i // 2
            keta[j] += v
    for i, v in enumerate(keta):
        c = v * (n-v) % MOD
        ans += c * kaizyo[i] % MOD
        ans = ans % MOD

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

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

tree = [[i] for i in range(N+1)]
points = [0] * N

for i in range(1, N):
  a, b = map(int, input().split())
  tree[a].append(b)
  for j in range(i):
    if a in tree[j]:
      tree[j].append(b)
      
for i in range(Q):
  p, x = map(int, input().split())
  for node in set(tree[p]):
    points[node-1] += x
    
for point in points:
  print(point, end=" ")

### FIXED CODE ###

n,q = map(int,input().split())
rl = [0] * n
scores = [0] * n
for i in range(n-1):
    a,b = map(int,input().split())
    rl[b-1] = a-1
for j in range(q):
    p,x = map(int,input().split())
    scores[p-1] += x
for k in range(1,n):
    scores[k] += scores[rl[k]]
print(*scores)
### BUGGY CODE ###

#!/usr/bin/python3

import sys
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra

def input():
    return sys.stdin.readline().rstrip('\n')

N = int(input())

V = [[0]*N for _ in range(N)]

for i in range(N-1):
    u,v,w = list(map(int, input().split()))
    V[u-1][v-1] = w

D = dijkstra(csr_matrix(V), directed=False, indices=0)
#print(D)

for d in D:
    if d % 2 == 0: #even
        print(0)
    else:
        print(1)


### FIXED CODE ###

#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys
#import numpy
#from collections import deque
sys.setrecursionlimit(10**5)

def input():
    return sys.stdin.readline().rstrip('\n')

N = int(input())

childsof = [[] for _ in range(N+1)]

for _ in range(N-1):
    u,v,w = list(map(int, input().split()))
    childsof[u].append((v,w))
    childsof[v].append((u,w))

distances = [-1]*(N+1)
distances[1] = 0

def dfs(i):
    childs = childsof[i]

    for c in childs:
        j = c[0]
        if distances[j] == -1:
            distances[j] = distances[i] + c[1]
            dfs(j)

dfs(1)

for d in distances[1:]:
    if d % 2 == 0: #even
        print(0)
    else:
        print(1)
### BUGGY CODE ###

#!/usr/bin/env python3
import sys


def solve(N: int, M: int, Q: int, L: "List[int]", R: "List[int]", p: "List[int]", q: "List[int]"):
    matrix = [[0]*(N+1) for _ in range(N+1)]

    for i in range(M):
        matrix[L[i]][R[i]] += 1

    for j in range(Q):
        answer = 0
        for k in range(p[j],q[j]+1): 
            for l in range(p[j],q[j]+1):
                answer += matrix[k][l]
        print(answer)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    L = [int()] * (M)  # type: "List[int]"
    R = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        L[i] = int(next(tokens))
        R[i] = int(next(tokens))
    p = [int()] * (Q)  # type: "List[int]"
    q = [int()] * (Q)  # type: "List[int]"
    for i in range(Q):
        p[i] = int(next(tokens))
        q[i] = int(next(tokens))
    solve(N, M, Q, L, R, p, q)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys


def solve(N: int, M: int, Q: int, L: "List[int]", R: "List[int]", p: "List[int]", q: "List[int]"):
    matrix = [[0]*(N+1) for _ in range(N+1)]

    for i in range(M):
        matrix[L[i]][R[i]] += 1

    ruisekiwa = [[0]*(N+1) for _ in range(N+1)]
    for i in range(N):
        for j in range(N):
            ruisekiwa[i+1][j+1] = ruisekiwa[i][j+1] + ruisekiwa[i+1][j] - ruisekiwa[i][j] + matrix[i+1][j+1]
    for j in range(Q):
        qq = q[j]
        pp = p[j]
        answer = ruisekiwa[qq][qq] - ruisekiwa[qq][pp-1] - ruisekiwa[pp-1][qq] + ruisekiwa[pp-1][pp-1]

        print(answer)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    L = [int()] * (M)  # type: "List[int]"
    R = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        L[i] = int(next(tokens))
        R[i] = int(next(tokens))
    p = [int()] * (Q)  # type: "List[int]"
    q = [int()] * (Q)  # type: "List[int]"
    for i in range(Q):
        p[i] = int(next(tokens))
        q[i] = int(next(tokens))
    solve(N, M, Q, L, R, p, q)

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

def main():
    n, k = map(int, input().split())
    aa = sorted(list(map(int, input().split())))
    f = sorted(list(map(int, input().split())), reverse=True)

    def b_search(a, b):
        while a+1 < b:
            med = (a+b)//2
            cnt = 0
            for i in range(n):
                cnt += max(aa[i]-med//f[i], 0)
            if cnt > k:
                a = med+1
            else:
                b = med
        if a == b:
            return a
        else:
            cnt = 0
            for i in range(n):
                cnt += max(aa[i]-a//f[i], 0)
            if cnt > k:
                return b
            else:
                return a

    print(b_search(0, 10**12+10))


main()


### FIXED CODE ###

def main():
    n,k=map(int,input().split())
    a=sorted(list(map(int,input().split())))
    f=sorted(list(map(int,input().split())),reverse=True)
    def b_search(a,b,value,lim):
        med=(a+b)//2
        if a==b:return a
        elif lim=="upper":
            if a+1==b:
                if value(b):return b
                else:return a
            elif value(med):return b_search(med,b,value,lim)
            else:return b_search(a,med-1,value,lim)
        else:
            if a+1==b:
                if value(a):return a
                else:return b
            elif value(med):return b_search(a,med,value,lim)
            else:return b_search(med+1,b,value,lim)

    def count(val):
        cnt=0
        for i in range(n):
            cnt+=max(a[i]-val//f[i],0)
        if cnt>k:
            return False
        else:
            return True
    
    print(b_search(0,10**12+10,count,"lower"))
    
main()
### BUGGY CODE ###

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

y = []
for i in range(n):
    y.append(x[i] - a)

if n == 1:
    if x[0] == a:
        print(1)
    else:
        print(0)
else:
    g1 = []
    g2 = []

    for i in range(2 ** (n // 2)):
        h = 0
        for j in range(n // 2):
            flag = i >> j & 1
            h += y[j] * flag
        g1.append(h)

    m = n - n // 2
    for i in range(2 ** m):
        h = 0
        for j in range(m):
            flag = i >> j & 1
            h += y[n // 2 + j] * flag
        g2.append(h)

    g2.sort()

    ans = 0
    import bisect

    for i in g1:
        left = bisect.bisect_left(g2, -i)
        right = bisect.bisect(g2, -i)
        ans += right - left

    print(ans-1)


### FIXED CODE ###

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

y = []
for i in range(n):
    y.append(x[i] - a)

dp = [[0 for i in range(110*n)] for j in range(n+1)]

const = 50*n
dp[0][const] = 1


for i in range(n):
    for j in range(100*n + 1):
        dp[i+1][j] = dp[i][j]
        if j - y[i] >= 0 and j - y[i] <= 100*n:
            dp[i+1][j] += dp[i][j - y[i]]

print(dp[n][const]-1)