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

N,M=list(map(int,input().split()))
A=list(map(int,input().split()))
while M>0:
    B=max(A)
    A[A.index(max(A))]=A[A.index(max(A))]//2
    M-=1
print(sum(A))

### FIXED CODE ###

import heapq
N,M=list(map(int,input().split()))
A=list(map(int,input().split()))
A=[-A[i] for i in range(N)]
heapq.heapify(A)
for i in range(M):
    a=A[0]
    heapq.heappop(A)
    heapq.heappush(A,-(a//-2))
print(-sum(A))
### BUGGY CODE ###

N,M=map(int,input().split())
list1=list(map(int,input().split()))
for _ in range(M):
  B,C=map(int,input().split())
  list1+=[C]*B
list1.sort(reverse=True)
list1=list1[:N]
SUM=sum(list1)
print(SUM)

### FIXED CODE ###

N,M = map(int, input().split())
listA = list(map(int, input().split()))
listA.sort()
 
listBC = [list(map(int, input().split())) for i in range(M)]
listBC = sorted(listBC, key=lambda x: x[1], reverse=True)
countB = 0
 
for i in range(M):
  B, C = listBC[i][0], listBC[i][1]
  listA += [C]*B
  countB += B
  if countB >= N:
    break

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

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

a_types = set(A)

count_dict = {}
for each in a_types:
    count_dict[each] = A.count(each)

all_types = 0
for value in count_dict.values():
    all_types += value * (value - 1) / 2

for a in A:
    print(int(all_types - count_dict[a] + 1))
# no_execlusion_results = {}
# for each in a_types:
#     no_execlusion_results[each] = 
# result_dict = {}
# for each in a_types:
#     tmp_dict = copy.deepcopy(count_dict)
#     tmp_dict[each] = count_dict[each] - 1
#     combinations = 0
#     for value in tmp_dict.values():
#         combinations += int(value * (value - 1) / 2)
#     result_dict[each] = combinations
# 
# print(result_dict)
# for a in A:
#     print(result_dict[a])

### FIXED CODE ###

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

c = [0]*n

for i in range(n):
    c[a[i]-1] = c[a[i]-1] + 1
    
total = 0
for x in c:
    total = total + x*(x-1)//2

for i in range(n):
    print(total - c[a[i]-1] + 1)
### BUGGY CODE ###

#https://atcoder.jp/contests/dp/tasks/dp_d
#2019-01-13
N, W = map(int, input().split())
w, v = [], []
for i in range(N):
    a, b = map(int, input().split())
    w += [a]
    v += [b]

ans = 0
for i in range(1 << N):
    cnt = 0
    weight = 0
    for j in range(N):
        if i & 1<<j:
            cnt += v[j]
            weight += w[j]
    if weight <= W:
        ans = max(ans, cnt)
print(ans)

### FIXED CODE ###

#https://atcoder.jp/contests/dp/tasks/dp_d
#2019-01-13
N, W = map(int, input().split())
w, v = [], []
for i in range(N):
    a, b = map(int, input().split())
    w += [a]
    v += [b]

DP = [0] * (W+1)
# i 円以下で買える商品の最大価値
for i in range(N):
    for weight in range(W,-1,-1):
        if weight - w[i] < 0 :continue
        DP[weight] = max(DP[weight], DP[weight - w[i]] +v[i])
print(DP[-1])
### BUGGY CODE ###

def 解():
    sS = input().rstrip()
    sT = input().rstrip()
    iS = len(sS)
    iT = len(sT)

    dp = [[""]*(iT+1) for _ in range(2)]
    for i in range(iS):
        OE0 = i&1
        OE1 = (i+1)&1
        for j in range(iT):
            if sS[i] == sT[j]:
                dp[OE1][j+1] = dp[OE0][j] + sS[i]
            else:
                s1 = dp[OE1][j]
                s2 = dp[OE0][j+1]
                if len(s1) > len(s2):
                    dp[OE1][j+1] = s1
                else:
                    dp[OE1][j+1] = s2
    print(dp[iS&1][iT])
解()


### FIXED CODE ###

def 解():
    sS = input().rstrip()
    sT = input().rstrip()
    iS = len(sS)
    iT = len(sT)

    dp = [[0]*(iT+1) for _ in range(iS+1)]
    for i in range(iS):
        for j in range(iT):
            if sS[i] == sT[j]:
                dp[i+1][j+1] = dp[i][j] + 1
            else:
                dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1])
    iC = dp[iS][iT]
    aR = [""]*iC
    i = iS
    j = iT
    while 0 < i and 0 < j:
        if sS[i-1] == sT[j-1]:
            aR[dp[i][j]-1]=sS[i-1]
            i -= 1
            j -= 1
        else:
            if dp[i][j] == dp[i][j-1] :
                j -= 1
            elif dp[i][j] == dp[i-1][j] :
                i -= 1
            else:
                break

    print("".join(aR))
    exit()

    def findS(i,j):
        iC = dp[i][j]
        if iC == 0 or aR[iC-1] != "":
            return False
        if dp[i][j] == dp[i-1][j] + 1 == dp[i][j-1] +1 :
            t = dp[i][j]
            aR[t-1] = sS[i-1]
            findS(i-1,j-1)
        else:
            findS(i-1,j)
            findS(i,j-1)
    findS(i,j)
    print("".join(aR))
解()
### BUGGY CODE ###

n, k = map(int, input().split())
li = []
for i in range(n):
    a, b = map(int, input().split())
    for j in range(b):
        li.append(a)
li.sort()
print(li[k-1])

### FIXED CODE ###

n, k = map(int, input().split())
li = []
for i in range(n):
    temp = list(map(int, input().split()))
    li.append(temp)
#print(li)
li.sort()
#print(li)
total=0
for i in range(n):
    if i==n-1:
        #print("here")
        print(li[i][0])
        break
    total+=li[i][1]
    if total<k:
        continue
    else:
        print(li[i][0])
        break
    #print(i, total)
### BUGGY CODE ###



import collections
import itertools
import sys


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

s = list(input())
t = list(input())
n = len(s)
mp = dict()

cnt = 0
while s != t:
    for i in range(n):
        if s[i] != t[i]:
            c1, c2 = s[i], t[i]
            for j in range(n):
                if s[j] == c1:
                    s[j] = c2
                elif s[j] == c2:
                    s[j] = c1
    cnt += 1
    if cnt > 100:
        break

ok = s == t

print("Yes" if ok else "No")

### FIXED CODE ###



import collections
import itertools
import sys


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

s = input()
t = input()

ss = [s.find(c) for c in s]
tt = [t.find(c) for c in t]

print("Yes" if ss == tt else "No")
### BUGGY CODE ###

A=input()
K=int(input())
A2=list(A.strip())
A2=set(A2)
A2=list(A2)
A2.sort()
Ans=A2[0]

def solve(st,s,k,li):
  an=set(s)
  lin=0
  while len(an)<=k:
    ch=False
    for i in range(len(st)):
      if st[i]==s:
        cnt=2
        while i+cnt<=len(st) or cnt<5:
          an.add(st[i:i+cnt])
          cnt+=1
    if len(an)<K:
      lin+=1
      s=li[lin]
      an.add(s)
      cnt=2
      
  an=list(an)
  an.sort()
  return an[k-1]

if K==1:
  print(Ans)
else:
  print(solve(A,Ans,K,A2))

### FIXED CODE ###

s=input()
K=int(input())

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

n = int(input())
a = [0] * n
for i in range(n):
    a[i] = int(input())
aa = sorted(a)
if aa[-1] == aa[-2]:
    for i in range(n):
        print(aa[-1])
else:
    for i in range(n):
        if i == a.index(aa[-1]):
            print(aa[-2])
        else:
            print(aa[-1])

### FIXED CODE ###

n = int(input())
a = [int(input()) for i in range(n)]
maxi = max(a)
s = sorted(a,reverse=True)
 
for i in range(n):
    if a[i] != maxi:
        print(maxi)
    else:
        print(s[1])
### BUGGY CODE ###

# -*- coding: utf-8 -*-

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

res = 1
thr = 10**18
for a in A:
    res *= a

    if res > thr:
        res = -1

if 0 in A:
    res = 0

print(res)


### FIXED CODE ###

# coding: utf-8

#import numpy as np

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

thr = 10**18

res = 1

if 0 in A:
    res = 0
else:
    for a in A:

        res *= a

        if res > thr:
            res = -1
            break

print(int(res))
### BUGGY CODE ###

from collections import defaultdict
from collections import deque
n,q = map(int,input().split())
d = defaultdict(list)
dp = defaultdict(int)
ep = [0] * n
for i in range(n-1):
    ta,tb = map(int,input().split())
    d[ta-1].append(tb-1)
    d[tb-1].append(ta-1)
for i in range(q):
    ta,tb = map(int,input().split())
    dp[ta-1] +=tb
ep[0]+=1
l = deque()
l.append(0)
while l:
    t = l.pop()
    for i in d[t]:
        if ep[i] == 0:
            dp[i] += dp[t]
            ep[i]+=1
            l.append(i)
ans = []
for i in dp:
    print(dp[i],end=' ')

### FIXED CODE ###

from collections import defaultdict
from collections import deque
n,q = map(int,input().split())
d = defaultdict(list)
dp = [0] * n
ep = [0] * n
for i in range(n-1):
    ta,tb = map(int,input().split())
    d[ta-1].append(tb-1)
    d[tb-1].append(ta-1)
for i in range(q):
    ta,tb = map(int,input().split())
    dp[ta-1] +=tb
ep[0]+=1
l = deque()
l.append(0)
used = [False] * n
while l:
    t = l.pop()
    used[t] = True
    for i in d[t]:
        if not used[i]:
            dp[i] += dp[t]
            l.append(i)
print(*dp)
### BUGGY CODE ###

X = int(input())

flag = 0

for a in range(int(X/100)+1):
	for b in range(int(X/100)+1):
		for c in range(int(X/100)+1):
			for d in range(int(X/100)+1):
				for e in range(int(X/100)+1):
					for f in range(int(X/100)+1):
						if 100*a + 101*b + 102*c + 103*d + 104*e + 105*f == X:
							flag = 1
							break
						else:
							continue

print(flag)

### FIXED CODE ###

X = int(input())

import numpy as np

J = np.zeros(X+1, dtype="bool")
# J[i] は、 i円の買い物ができるときにTrue, できないとFalse
J[0] = True
J[1:100] = False
J[100:106] = True
for i in range(106, X+1):
    if J[i - 100] or J[i - 101] or J[i - 102] or J[i - 103] or J[i - 104] or J[i - 105]:
        J[i] = True
    else:
        J[i] = False

if J[X] == True:
    print("1")
else:
    print("0")
### BUGGY CODE ###

#!/usr/bin/env python3
from collections import Counter
n = int(input())
s = input()
# n=10**3
# s='abcab'*(10**3)
count = 0
for le in range(n//2+1,0,-1):
    mojiretu = Counter()
    for i in range(n-le+1):
        j = i+le
        if 0 < mojiretu[s[i:j]] <= i:
            print(le)
            exit()
        else:
            mojiretu[s[i:j]] = j
print(count)

### FIXED CODE ###

N=int(input())
S=input()

class RollingHash():
    BASE1 = 1007
    BASE2 = 2009
    MOD1 = 1000000007
    MOD2 = 1000000009
 
    def __init__(self, s, opt=2):
        self.n = len(s)
        self.opt = opt
        self.hash1 = [0] * (self.n + 1)
        self.power1 = [1] * (self.n + 1)
        if opt == 2:
            self.hash2 = [0] * (self.n + 1)
            self.power2 = [1] * (self.n + 1)
        for i, e in enumerate(s):
            self.hash1[i + 1] = (self.hash1[i] * self.__class__.BASE1 + ord(e)) % self.__class__.MOD1
            self.power1[i + 1] = (self.power1[i] * self.__class__.BASE1) % self.__class__.MOD1
            if opt == 2:
                self.hash2[i + 1] = (self.hash2[i] * self.__class__.BASE2 + ord(e)) % self.__class__.MOD2
                self.power2[i + 1] = (self.power2[i] * self.__class__.BASE2) % self.__class__.MOD2
 
    def get(self, l: int, r: int):
        res1 = self.hash1[r] - self.hash1[l] * self.power1[r - l] % self.__class__.MOD1
        if(res1 < 0):
            res1 += self.__class__.MOD1
        if self.opt == 2:
            res2 = self.hash2[r] - self.hash2[l] * self.power2[r - l] % self.__class__.MOD2
            if(res2 < 0):
                res2 += self.__class__.MOD2
        return (res1, res2) if self.opt == 2 else res1


    
rh = RollingHash(S, opt=1)

def check(n: int):
    d = dict()
    for i in range(N - n + 1):
        p = rh.get(i, i + n)
        if p in d.keys():
            if(i - d[p] >= n):
                return True
        else:
            d[p] = i
    return False
    
ok, ng = 0, N // 2 + 1
while ng - ok > 1:
    mid = (ok + ng) // 2
    if check(mid):
        ok = mid
    else:
        ng = mid
print(ok)
### BUGGY CODE ###

a,b,c,k = map(int,input().split())
p = []
for m in range(a+1) :
    for n in range(b+1) :
        for l in range(c+1) :
            if k == m+n+l :
                p.append(1*m+0*n+(-1)*l)
print(max(p))

### FIXED CODE ###

a,b,c,k = map(int,input().split())
if k <= a :
    print(k)
else :
    m = min(k,a)
    k -= a

    if k <= b :
        print(a)
    else :
        n = min(k,b)
        k -= b
        l = k
        print(1*m+(-1)*l)
### BUGGY CODE ###

N = int(input())
ans = 1
for i in range(1, N + 1):
	ans *= i
print(ans % (pow(10, 9) + 7))

### FIXED CODE ###

import math
N = int(input())
ans = math.factorial(N)
print(ans % (pow(10, 9) + 7))
### BUGGY CODE ###

from itertools import product

x1 = int(input())
x2 = input()

R = [i for i, x in enumerate(x2) if x == "R"]
G = [i for i, x in enumerate(x2) if x == "G"]
B = [i for i, x in enumerate(x2) if x == "B"]

_sum = 0
for i in product(R, G, B):
    group = sorted(i)
    if (group[1] - group[0]) != (group[2] - group[1]):
        _sum += 1
print(_sum)

### FIXED CODE ###

from itertools import product

x1 = int(input())
x2 = input()

R_i = [i for i, x in enumerate(x2) if x == "R"]
G_i = [i for i, x in enumerate(x2) if x == "G"]
B_i = {i for i, x in enumerate(x2) if x == "B"}

R = len(R_i)
G = len(G_i)
B = len(B_i)

xs = map(sorted, product(R_i, G_i))

s = 0
for a in xs:
    k = a[1]*2 - a[0]  # 2j-i
    if k in B_i:
        s +=1
    i = a[0]*2 - a[1]  # 2j-k
    if i in B_i:
        s +=1
    j = (a[0] + a[1]) / 2
    if j.is_integer():
        j = int(j)
        if j in B_i:
            s +=1
print(R*G*B - s)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

h, w = map(int, input().split())
a = [tuple(map(int, input().split())) for _ in range(h)]
b = [tuple(map(int, input().split())) for _ in range(h)]
c = [[a[i][j] - b[i][j] for j in range(w)] for i in range(h)]

dp = [[set() for _ in range(w)] for _ in range(h)]
dp[0][0].add(c[0][0])

for i in range(h):
    for j in range(w):
        for x in dp[i][j]:
            if i < h - 1:
                dp[i + 1][j].add(abs(x + c[i + 1][j]))
                dp[i + 1][j].add(abs(x - c[i + 1][j]))

            if j < w - 1:
                dp[i][j + 1].add(abs(x + c[i][j + 1]))
                dp[i][j + 1].add(abs(x - c[i][j + 1]))

print(min(dp[h - 1][w - 1]))


### FIXED CODE ###

import sys
input = sys.stdin.readline

h, w = map(int, input().split())
a = [tuple(map(int, input().split())) for _ in range(h)]
b = [tuple(map(int, input().split())) for _ in range(h)]
c = [[abs(a[i][j] - b[i][j]) for j in range(w)] for i in range(h)]

CONST = 80 * 80 * 2
dp = [[0] * w for _ in range(h)]
dp[0][0] = 1 << (c[0][0] + CONST)

for i in range(h):
    for j in range(w):
        if i < h - 1:
            dp[i + 1][j] |= (dp[i][j] << c[i + 1][j])
            dp[i + 1][j] |= (dp[i][j] >> c[i + 1][j])
        if j < w - 1:
            dp[i][j + 1] |= (dp[i][j] << c[i][j + 1])
            dp[i][j + 1] |= (dp[i][j] >> c[i][j + 1])

for k in range(CONST):
    if dp[h - 1][w - 1] & (1 << (CONST + k)) != 0 or dp[h - 1][w - 1] & (
            1 << (CONST - k)) != 0:
        ans = k
        break

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

import bisect
N = int(input())
A = [int(input()) for n in range(N)]

tree = [[A[0]]]
leaf = [A[0]]
for n in range(1,N):
    a = A[n]
    pos = min(n-1,bisect.bisect_left(leaf,a)-1)
    if pos==-1:
        tree.insert(0,[a])
        leaf.insert(0,a)
    else:
        tree[pos].append(a)
        leaf[pos] = a
print(len(tree))

### FIXED CODE ###

import bisect
from collections import deque
N = int(input())
A = [int(input()) for n in range(N)]

tree = deque([[A[0]]])
leaf = deque([A[0]])
for n in range(1,N):
    a = A[n]
    pos = min(n-1,bisect.bisect_left(leaf,a)-1)
    if pos==-1:
        tree.appendleft([a])
        leaf.appendleft(a)
    else:
        tree[pos].append(a)
        leaf[pos] = a
print(len(tree))
### BUGGY CODE ###

N = int(input())

lis = [0]*60

for a in input().split():
    a = int(a)
    for i in range(60):
        lis[i] += a % 2
        a = a//2
ans = 0
for i, j in enumerate(lis):
    ans += j * (N-j) *(2**i)
    ans = ans % (10**9 + 7)

print(ans)

### FIXED CODE ###

N = int(input())
 
lis = [0]*60
 
for a in input().split():
    a = int(a)
    for i in range(60):
        lis[i] += a % 2
        a = a//2
ans = 0
for i, j in enumerate(lis):
    ans += j * (N-j) *(2**i)
    ans = ans % (10**9 + 7)
 
print(ans)
### BUGGY CODE ###

N = int(input())
X = list(map(int, input().split()))
Y = 1
for i in range(0, N):
  Y = X[i] * Y
if Y <= 10 ** 18:
  print(Y)
else:
  print(-1)

### FIXED CODE ###

import sys

N = int(input())
X = list(map(int, input().split()))
if min(X) == 0:
  print(0)
  sys.exit()
Y = X[0]
for i in range(1, N):
  Y = X[i] * Y
  if Y > 10 ** 18:
    print(-1)
    sys.exit()
print(Y)
### BUGGY CODE ###

from queue import Queue as queue

def main():
    h, w = map(int, input().split())
    s = [input() for i in range(h)]

    inf = h * w
    dp = [[inf for j in range(w)] for i in range(h)]

    q = queue()
    for i, si in enumerate(s):
        for j, sij in enumerate(si):
            if sij == '#':
                q.put((i, j), False)
                dp[i][j] = 0

    dijs = list(zip([-1, 0, 1, 0], [0, -1, 0, 1]))
    while not q.empty():
        i, j = q.get(False)
        for di, dj in dijs:
            ni = i + di
            nj = j + dj
            if not (0 <= ni < h and 0 <= nj < w): continue
            if dp[ni][nj] <= dp[i][j] + 1: continue
            q.put((ni, nj), False)
            dp[ni][nj] = dp[i][j] + 1

    print(max(max(dpi) for dpi in dp))

main()

### FIXED CODE ###

from collections import deque

def main():
    h, w = map(int, input().split())
    s = [input() for i in range(h)]

    inf = h * w
    dp = [[inf for j in range(w)] for i in range(h)]

    q = deque()
    for i, si in enumerate(s):
        for j, sij in enumerate(si):
            if sij == '#':
                q.append((i, j))
                dp[i][j] = 0

    dijs = list(zip([-1, 0, 1, 0], [0, -1, 0, 1]))
    while q:
        i, j = q.popleft()
        for di, dj in dijs:
            ni = i + di
            nj = j + dj
            if not (0 <= ni < h and 0 <= nj < w): continue
            if dp[ni][nj] <= dp[i][j] + 1: continue
            q.append((ni, nj))
            dp[ni][nj] = dp[i][j] + 1

    print(max(max(dpi) for dpi in dp))

main()
### BUGGY CODE ###

s = list(input())
k = int(input())
ansnum = 0

while(ansnum < k):
    #print(s)
    for j in range(k):
        listj = []
        for i in range(len(s)-j):
            #print(s[i:i+j+1])
            listj.append(s[i:i+j+1])
        listj.sort()
        # print('listj:',listj)
        # print('j:',j)
        if len(listj) >= 2 and listj[0] == listj[1]:
            # print('choufuku')
            pass
        else:
            # j+1文字で重複なしの場合(j=0,1,2,3,4)
            s = ''.join(s)
            for i in range(len(listj)):
                num = s.index(''.join(listj[i]))
                # print('index:',num)
                # print('ansnum:',ansnum)
                if (len(s) - num) < k - ansnum:
                    ansnum += len(s) - num
                else:
                    ans = s[num:num + k - ansnum]
                    ansnum = k + 1
                    break
        if ansnum > k:
            break

#print('ans:',ans)
print(ans)

### FIXED CODE ###

s = list(input())
k = int(input())
subs = []
for i in range(min(k,len(s))):
  for j in range(len(s)-i):
    subs.append(''.join(s[j:j+i+1]))
subs = list(set(subs))
subs.sort()
#print(subs)
print(subs[k-1])
### BUGGY CODE ###

#!/usr/bin/env python3

def solve(x):
    if x >= 2000:
        return True
    memo = [True] + [False]*x

    def dp(k):
        if k == 0:
            return True
        elif k < 0:
            return False
        elif memo[k]:
            return True
        for i in range(100,106):
            if dp(k-i):
                memo[k-i] = True
                return True
        
        return False

    return dp(x)



def main():
    X = int(input())
    print(int(solve(X)))
    return

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3

def solve(x):
    if x >= 2000:
        return True
    memo = [True] + [False]*x

    def dp(k):
        if k == 0:
            return True
        for i in range(100,106):
            if k-i >= 0 and memo[k-i]:
                return True
        
        return False
    
    for i in range(x):
        memo[i+1] = dp(i+1)
    return memo[x]



def main():
    X = int(input())
    print(int(solve(X)))
    return

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

import numpy as np
N,K=map(int,input().split())
A=[int(i) for i in input().split()]
F=[int(i) for i in input().split()]
A.sort()
F.sort()
F = F[::-1]
s=sum(A)
l=-1
r=10**12+2
while l+1<r:
    m=(l+r)//2
    temp = s
    for i in range(N):
      temp -= min(A[i],m//F[i])
    if temp <= K:
        r=m
    else:
        l=m
print(r)

### FIXED CODE ###

import numpy as np
N,K=map(int,input().split())
A=np.array(sorted(list(map(int,input().split()))))
F=np.array(sorted(list(map(int,input().split())), reverse=True))
s=A.sum()
l=-1
r=10**12+2
while l+1<r:
    m=(l+r)//2
    if s-np.minimum(A,m//F).sum()<=K:
        r=m
    else:
        l=m
print(r)
### BUGGY CODE ###

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

sm = 0
for i in range(0, n):
    sm = sm + a[i]

min_dif = sm

p = 0
for i in range(n-3):
    p = p + a[i]
    if 4*p <= sm - 3*min_dif or 4*p >= sm + 3*min_dif:
        next
    q = 0
    for j in range(i+1, n-2):
        q = q + a[j]
        if 4*q <= sm - 3*min_dif or 4*q >= sm + 3*min_dif:
            next
        r = 0
        for k in range(j+1, n-1):
            r = r + a[k]
            if 4*r <= sm - 3*min_dif or 4*r >= sm + 3*min_dif:
                next
            s = 0
            for l in range(k+1, n):
                s = s + a[l]
            d = max([p, q, r, s])-min([p, q, r, s])
            min_dif = min([d, min_dif])

print(min_dif)


### FIXED CODE ###

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

t = list(0 for i in range(n+1))
for i in range(1, n+1):
    t[i] = t[i-1] + a[i-1]

def sum_a(i, j):
    return t[j]-t[i]

min_dif = sum_a(0, n)

i = 0
k = 2
for j in range(2, n-1):
    u = sum_a(0, j) // 2
    while sum_a(0, i) < u:
        i = i + 1
    if abs(sum_a(0, i-1)-sum_a(i-1, j)) < abs(sum_a(0, i) - sum_a(i, j)): 
        i = i - 1
    p = sum_a(0, i)
    q = sum_a(i, j)

    u = sum_a(j, n) // 2
    while sum_a(j, k) < u:
        k = k + 1
    if abs(sum_a(j, k-1)-sum_a(k-1, n)) < abs(sum_a(j, k) - sum_a(k, n)): 
        k = k - 1
    r = sum_a(j, k)
    s = sum_a(k, n)

    min_dif = min(min_dif, max(p, q, r, s)-min(p, q, r, s))

print(min_dif)
### BUGGY CODE ###

N = int(input())
A = tuple(map(int, input().split()))
mod = 10**9+7

ans = 0
for k in range(0, 100):
    num1 = 0
    num0 = 0
    for a in A:
        if (a >> k) & 1:
            num1 += 1
        else:
            num0 += 1

    ans += num1 * num0 * pow(2, k) % mod
    ans %= mod

print(ans)


### FIXED CODE ###

N = int(input())
A = tuple(map(int, input().split()))
mod = 10**9+7

def solve(N, A):
    ans = 0
    for k in range(61):
        num1 = 0
        for a in A:
            if (a >> k) & 1:
                num1 += 1
        ans += (num1 * (N-num1)) << k
        ans %= mod
    return ans
    
print(solve(N, A))
### BUGGY CODE ###

n = int(input())
power = 1
for i in range(1,n+1):
    power *= i
print(power%(10**9+7))

### FIXED CODE ###

n = int(input())
power = 1
for i in range(1,n+1):
    power = i*power%(10**9+7)
print(power)