Harryxun/stf_run huggingface dataset:
l,r = list(map(int,input().split()))

l = l % 2019
r = r % 2019
l = min(l,r)
r = max(l,r)
if r == l:
  print((r*l) %2019)
  exit()
for i in range(l,r+1):
  for j in range(i,r+1):
    if i != j:
      ans += [(i * j) %2019]
      
print(min(ans))


### FIXED CODE ###

l,r = list(map(int,input().split()))
if r-l >= 2019:
  print(0)
  exit()
l = l % 2019
r = r % 2019
l = min(l,r)
r = max(l,r)
ans = []
if r == l:
  print(0)
  exit()
for i in range(l,r+1):
  for j in range(i,r+1):
    if i != j:
      ans += [(i * j) %2019]
      
print(min(ans))
a, b = map(int, inpput().split())
print((a + b) % 24)


### FIXED CODE ###

a, b = map(int, input().split())
print((a + b) % 24)
N,L=map(int, input().split())
str_lists = []
for i in xrange(N):
  str_lists.append(input())
print(''.join(sorted(str_lists)))

### FIXED CODE ###

N,L=map(int, input().split())
str_lists = []
for i in range(N):
  str_lists.append(input())

print(''.join(sorted(str_lists)))
a,b,c=map(int,input())
print(max(0,c-(a-b))

### FIXED CODE ###

a,b,c=map(int,input().split())
print(max(0,c-(a-b)))
# import numpy as np

H, W, M = map(int, input().split())
# map_ = np.zeros((H, W), dtype=np.uint8)
map_ = [[0] * W for _ in range(H)]

h_sum = [0] * H
w_sum = [0] * W

for _ in range(M):
    h, w = map(int, input().split())
    map_[h-1, w-1] = 1
    h_sum[h-1] += 1
    w_sum[w-1] += 1

h_max = max(h_sum)
w_max = max(w_sum)

h_argmax = set()
w_argmax = set()

for i, h in enumerate(h_sum):
    if h == h_max:
        h_argmax.add(i) 

for i, w in enumerate(w_sum):
    if w == w_max:
        w_argmax.add(i)

ans = h_max + w_max

for h in h_argmax:
    for w in w_argmax:
        if map_[h, w] == 0:
            print(ans)
            exit()
print(ans - 1)

### FIXED CODE ###

# import numpy as np

H, W, M = map(int, input().split())
#map_ = np.zeros((H, W), dtype=np.bool)

h_sum = [0] * H
w_sum = [0] * W
point_list = set()

for _ in range(M):
    h, w = map(int, input().split())
    # map_[h-1, w-1] = 1
    point_list.add((h-1, w-1))
    h_sum[h-1] += 1
    w_sum[w-1] += 1

h_max = max(h_sum)
w_max = max(w_sum)

h_argmax = set()
w_argmax = set()

for i, h in enumerate(h_sum):
    if h == h_max:
        h_argmax.add(i) 

for i, w in enumerate(w_sum):
    if w == w_max:
        w_argmax.add(i)

ans = h_max + w_max

for h in h_argmax:
    for w in w_argmax:
        if (h, w) not in point_list:
        # if map_[h, w] == 0:
            print(ans)
            exit()
print(ans - 1)
a, b, k = map(int, input().split())
if k%2 == 0:
    for _ in range(int(k/2)):
        a = int(a/2)
        b += a
        b = int(b/2)
        a += b
    print(a ,b)
    
else:
    for _ in range((k-1/2)):
        a = int(a/2)
        b += a
        b = int(b/2)
        a += b
    a = int(a/2)
    b += a
    print(int(a),int(b))

### FIXED CODE ###

a, b, k = map(int, input().split())
if k%2 == 0:
    for _ in range(int(k/2)):
        a = int(a/2)
        b += a
        b = int(b/2)
        a += b
    print(a ,b)
    
else:
    for _ in range(int(k/2)):
        a = int(a/2)
        b += a
        b = int(b/2)
        a += b
    a = int(a/2)
    b += a
    print(int(a),int(b))
class Combination:
    '''
    計算量：階乗・逆元テーブルの作成O(N)
            nCkを求めるO(1)
    '''

    def __init__(self, n, MOD):
        self.fact = [1]
        for i in range(1, n + 1):
            self.fact.append(self.fact[-1] * i % MOD)
        self.inv_fact = [pow(self.fact[i] ,MOD - 2 ,MOD) for i in range(n + 1)]
        self.MOD = MOD

    def factorial(self, k):
        '''k!を求める'''
        return self.fact[k]

    def inverse_factorial(self, k):
        '''k!の逆元を求める'''
        return self.inv_fact[k]

    def combination(self, k, r):
        '''kCrを求める'''
        return (self.fact[k] * self.inv_fact[k - r] * self.inv_fact[r]) % self.MOD


n, a, b, k = map(int, input().split())
MOD = 998244353
comb = Combination(n, MOD)
ans = 0
for i in range(n+1):
    if not(k - a*i >= 0 and (k - a*i) % b == 0 and (k - a*i) % b <= n):
        continue
    else:
        ai = i
        bi = (k - a*i) // b
        ans += comb.combination(n, ai) * comb.combination(n, bi)
        ans %= MOD
print(ans)

### FIXED CODE ###

class Combination:
    '''
    計算量：階乗・逆元テーブルの作成O(N)
            nCkを求めるO(1)
    '''

    def __init__(self, n, MOD):
        self.fact = [1]
        for i in range(1, n + 1):
            self.fact.append(self.fact[-1] * i % MOD)
        self.inv_fact = [pow(self.fact[i] ,MOD - 2 ,MOD) for i in range(n + 1)]
        self.MOD = MOD

    def factorial(self, k):
        '''k!を求める'''
        return self.fact[k]

    def inverse_factorial(self, k):
        '''k!の逆元を求める'''
        return self.inv_fact[k]

    def combination(self, k, r):
        '''kCrを求める'''
        return (self.fact[k] * self.inv_fact[k - r] * self.inv_fact[r]) % self.MOD


n, a, b, k = map(int, input().split())
MOD = 998244353
comb = Combination(n, MOD)
ans = 0
for i in range(n+1):
    if not(k - a*i >= 0 and (k - a*i) % b == 0 and (k - a*i) // b <= n):
        continue
    else:
        ai = i
        bi = (k - a*i) // b
        ans += comb.combination(n, ai) * comb.combination(n, bi)
        ans %= MOD
print(ans)
N=int(input())
L=list(map(int,input().split()))
L.sort()
count = 0

for i in range(N):
  for j in range(i+1,N):
    summation = L[i] + L[j]
    subtract  = L[j] - L[i]
    D=L.copy()
    del D[j]
    del D[i]
    #E=[ D[k] for k in range(N) if k!= i and k!= j ]
    ##summationより小さいかを二分探索
    high = N-3
    low = 0
    if D[0] >= summation:
      upper = 0 #1つも満たさない
      #print(L[i],L[j],E,upper)
    elif D[-1] < summation:
      upper = N-2 #N-2個すべてOK
    else:
      while high > low+1:
        mid =(high + low) // 2
        if D[mid] >= summation: #大きすぎ
          high = mid
          # mid = low
        else: #小さすぎかちょうど
          low = mid
          # mid =high 
      upper = high
    #print("summation",summation,E,upper)
    ##subtractより大きいかを二分探索
    high = N-3
    low = 0
    if D[0] > subtract:
      lower = 0 #N-2個すべてOK
    elif D[-1] <= subtract:
      lower = N-2 #1つも満たさない
    else:
      while high > low+1:
        mid =(high + low) // 2
        if D[mid] > subtract: #大きすぎ
          high = mid
          # mid = low
        else: #小さすぎかちょうど
          low = mid 
          # mid =high 
      lower = high
    #print("subtract",subtract,E,lower)
    count += upper - lower
print(count//3)  

### FIXED CODE ###

from bisect import bisect_left
 
N = int(input())
L = sorted(list(map(int, input().split())))
 
ans = 0
for i in range(N):
    for j in range(i + 1, N):
        a = L[i]
        b = L[j]
        idx = bisect_left(L, a + b)
        ans += idx - 1 - j
print(ans)
import numpy as np
N = int(input())

furui = np.zeros(N+1, dtype=float)
for i in range(1, N+1):
    furui[i::i] += 1

for i in range(1, N+1):
    furui[i] = furui[i]*i

print(int(furui.sum()))




### FIXED CODE ###

N = int(input())

furui = [1]*(N+1)
ans = 1
for i in range(2, N+1):
    k = i
    while k <= N:
        furui[k] += 1
        k += i
    ans += furui[i]*i

print(ans)
import sys
input = sys.stdin.readline

N,M = map(int, input().split())
abc = [[int(j) for j in input().split()] for _ in range(M)]
con=[[] for _ in range (N+1)]
inf = float("inf")

allcost = [ -inf] * (N+1)
allcost[1] = 0

for i in range(M):
    a,b,c = abc[i]
    con[a].append(b)

for n in range(1, N):
    for edge in range(M):
        a,b,c = abc[edge]
        if allcost[b] < allcost[a] + c:
            allcost[b] = allcost[a] + c
def dfs(a):
  if N in con[a]:
    return True
  if len(con[a])==0:
    return False
  tmp=False 
  for ch in con[a]:
    if dfs(ch):
      tmp=True 
      break
  return tmp
for edge in range(M):
    a,b,c = abc[edge]
    if allcost[a] + c > allcost[b]:
        if dfs(b):
          print("inf")
          exit(0)

print(allcost[N])





### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

N,M = map(int, input().split())
abc = [[int(j) for j in input().split()] for _ in range(M)]
con=[[] for _ in range (N+1)]
inf = float("inf")

allcost = [ -inf] * (N+1)
allcost[1] = 0

for i in range(M):
    a,b,c = abc[i]
    con[a].append(b)

for n in range(1, N):
    for edge in range(M):
        a,b,c = abc[edge]
        if allcost[b] < allcost[a] + c:
            allcost[b] = allcost[a] + c
neg=[False]*(N+1)
for edge in range(M):
    a,b,c = abc[edge]
    if allcost[a] + c > allcost[b]:
        neg[b]=True
    if neg[a]==True:
      neg[b]=True
if neg[N]:
  print("inf")
  exit(0)
print(allcost[N])
N=int(input())
A=[int(x)for x in input().split()]
B=[]
if N%2==0:
    B= sorted([2*i-1 for i in range(1,N//2+1)]*2)
    if sorted(A)==B:
        ans=(pow(2,N/2))%(10**9+7)
    else:
        ans=0
else:
    B= [0]+sorted([2*i for i in range(1,N//2+1)]*2)
    if sorted(A)==B:
        ans=(pow(2,(N-1)/2))%(10**9+7)
    else:
        ans=0
print(int(ans))

### FIXED CODE ###

A,op,B=input().split()
if op=='-':
    print(int(A)-int(B))
else:
    print(int(A)+int(B))
import numpy as np


def calc_mul4_dp(n, aaa):
    # dp[i] = aaa[i] 以右をascendingにするために4をかける必要のある回数

    # 「支配的」である数と位置を記録するstack
    # 支配的: それを4倍すると、それより右で次に支配的な数までは全て4倍する必要のある数
    # (支配的な数, ←をいじらなかった場合の支配区間の最後の数, 最初の数の位置)
    stack = [(10 ** 20, 10 ** 20, n), (aaa[-1], aaa[-1], n - 1)]
    result = [0, 0]

    for i in range(n - 2, -1, -1):
        a = aaa[i]
        c = a
        inc = 0
        while (c << 2) > stack[-1][0]:
            b, e, j = stack.pop()
            mul = 0
            while c > b:
                b <<= 2
                mul += 1
            inc += mul * (stack[-1][2] - j)
            c = e << (2 * mul)
        stack.append((a, c, i))
        result.append(inc)
        # print(a, stack, result)
    result = np.add.accumulate(result, dtype=np.int64)[::-1]
    return result


def solve(n, aaa):
    fdp = calc_mul4_dp(n, aaa)
    bdp = calc_mul4_dp(n, aaa[::-1])[::-1]
    # print(fdp)
    # print(bdp)
    return ((fdp + bdp) * 2 + np.arange(n + 1, dtype=np.int64)).min()


def test():
    import random
    n = 200000
    # aaa = random.choices(range(1, 10 ** 9), k=n)
    # aaa = [1, 10 ** 9] * (n // 2)
    aaa = list(range(10 ** 9, 10 ** 9 - n, -1))
    print(n)
    # print(aaa)
    print(solve(n, aaa))


# test()

n = int(input())
aaa = list(map(int, input().split()))
print(solve(n, aaa))


### FIXED CODE ###

import numpy as np


def calc_mul4_dp(n, aaa):
    # dp[i] = aaa[i] 以右をascendingにするために4をかける必要のある回数

    # 「支配的」である数と位置を記録するstack
    # 支配的: それを4倍すると、それより右で次に支配的な数までは全て4倍する必要のある数
    # (支配的な数, ←をいじらなかった場合の支配区間の最後の数, 最初の数の位置)
    stack = [(10 ** 20, 10 ** 20, n), (aaa[-1], aaa[-1], n - 1)]
    INF = 10 ** 19
    result = [0, 0]

    for i in range(n - 2, -1, -1):
        a = aaa[i]
        c = a
        inc = 0
        while (c << 2) > stack[-1][0]:
            b, e, j = stack.pop()
            mul = 0
            while c > b:
                b <<= 2
                mul += 1
            inc += mul * (stack[-1][2] - j)
            c = min(e << (2 * mul), INF)
        stack.append((a, c, i))
        result.append(inc)
        # print(a, stack, result)
    result = np.add.accumulate(result, dtype=np.int64)[::-1]
    return result


def solve(n, aaa):
    fdp = calc_mul4_dp(n, aaa)
    bdp = calc_mul4_dp(n, aaa[::-1])[::-1]
    # print(fdp)
    # print(bdp)
    return ((fdp + bdp) * 2 + np.arange(n + 1, dtype=np.int64)).min()


def test():
    import random
    n = 200000
    # aaa = random.choices(range(1, 10 ** 9), k=n)
    # aaa = [1, 10 ** 9] * (n // 2)
    aaa = list(range(10 ** 9, 10 ** 9 - n, -1))
    print(n)
    # print(aaa)
    print(solve(n, aaa))


# test()

n = int(input())
aaa = list(map(int, input().split()))
print(solve(n, aaa))
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
b.reverse()
c = []
cs = -1
for i in range(n):
  if a[i] > b[i]:
    c.append(1)
  elif a[i] == b[i]:
    c.append(0)
    e = a[i]
    if cs == -1:
      cs = i
  else:
    c.append(-1)
#print(a)
#print(b)
#print(c)
ans = 0
for i in range(n):
  if a[i] == e:
    ans += 1
  if b[i] == e:
    ans += 1
if ans*2 > n:
  print('No')
else:
  print('Yes')
cnt = 0
for i in range(n):
  if cnt == ans:
    break
  if a[i] != e and b[i] != e:
    b[i],b[cs+cnt] = b[cs+cnt],b[i]
print(' '.join(map(str,b)))

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
b.reverse()
c = []
cs = -1
e = -1
for i in range(n):
  if a[i] > b[i]:
    c.append(1)
  elif a[i] == b[i]:
    c.append(0)
    e = a[i]
    if cs == -1:
      cs = i
  else:
    c.append(-1)
#print(a)
#print(b)
#print(c)
ans = 0
db = 0
for i in range(n):
  if a[i] == e:
    ans += 1
  if b[i] == e:
    ans += 1
  if a[i] == b[i]:
    db += 1
if ans > n:
  print('No')
  exit()
print('Yes')
cnt = 0
#print(b)
#print(cs,db)
for i in range(n):
  if cnt == db:
    break
  #print(i,a[i],b[i])
  if a[i] != e and b[i] != e:
    b[i],b[cs+cnt] = b[cs+cnt],b[i]
    cnt += 1
    #print(b)
print(' '.join(map(str,b)))
N,A,B = map(int,input().split())
S = sum(i for i in range(1,N+1) if A <= sum(list(map(int,str(i))) <= B)
print(S)



### FIXED CODE ###

N,A,B = map(int,input().split())
K = 0
for i in range(1,N+1):
  if A <= sum(map(int,str(i))) <= B:
    K += i
print(K)
while True:
    num = [int(i) for i in input().split("")]
    if num[0] == 0:
        break
    print(sum(num))
    
     

### FIXED CODE ###

while True:
    x = input()
    if x == "0":
        break
    num = [int(i) for i in x]
    print(sum(num))
a, b, c = map(int, input().spilt())
print('Yes' if a + b >= c else 'No')

### FIXED CODE ###

a, b, c = map(int, input().split())
print('Yes' if a + b >= c else 'No')
n,k= map(int,input().split())
h = [int(i) for i in input().split()]
inf = 10**7
dp = [inf]*100005
dp[0] = 0
for i in range(1,n):
    for j in range(1,k):
        if j > len(h):
            break
        dp[i+j] = min(dp[i+j],dp[i]+abs(h[i]-h[i+j]))
print(dp[n-1])

### FIXED CODE ###

def main():
    n,k= map(int,input().split())
    h = [int(i) for i in input().split()]
    inf = 10**7
    dp = [inf]*100005
    dp[0] = 0
    for i in range(1,n):
        dp[i] = min(dp[i-j] + abs(h[i-j] - h[i]) for j in range(1,min(k,i)+1))
    print(dp[n-1])
main()
N = int(input())
li = list(map(int, input().split()))
tmp = list()
ans = 'Yes'
for i in range(1, N):
    if li[i-1] > li[i]:
        tmp.append(li[i-1])
if len(tmp) != 2:
    ans == 'No'
else:
    t = li[tmp[0]]
    li[li.index(tmp[0])] = li[li.index(tmp[1])+1]
    li[li.index(tmp[1])+1] = t
    for i in range(N):
        if li[i-1] > li[i]:
            ans = 'No'
print(ans)

### FIXED CODE ###

N = int(input())
li = list(map(int, input().split()))
ans = list()
for i in range(N):
  if i+1 != li[i]:
    ans.append('groot')
if len(ans) <= 2:
  print('YES')
else:
  print('NO')
from sys import stdin
import numpy as np


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    K = int(_in[0])  # type:int
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    x_arr = np.arange(1,K+1)
    cnt = np.gcd.outer(np.gcd.outer(x_arr,x_arr),x_arr).sum()
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)
    

### FIXED CODE ###

import sys
import fractions

def in_ctrl():
    _input = [_.rstrip() for _ in sys.stdin.readlines()]
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    K = int(_input[0])
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    return K


def out_ctrl(s):
    print(s)


if __name__ == "__main__":
    K = in_ctrl()
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = 0
    dict_ = {}
    for a in range(1,K+1):
        cnt += a
        for b in range(a+1,K+1):
            if '{}_{}'.format(a,b) in dict_:
                ans = dict_['{}_{}'.format(a,b)]
            else:
                ans = fractions.gcd(a,b)
                dict_['{}_{}'.format(a,b)] = ans
            cnt += 6*ans
            for c in range(b+1,K+1):
                if '{}_{}'.format(ans,c) in dict_:
                    _ans = dict_['{}_{}'.format(ans,c)]
                else:
                    _ans = fractions.gcd(ans, c)
                    dict_['{}_{}'.format(ans,c)] = _ans
                cnt += 6*_ans
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    out_ctrl(cnt)
N = int(input())
F = [list(map(int,input().split())) for i in range(N)]
P = [list(map(int,input().split())) for i in range(N)]

ans = -10**9
for i in range(2**10-1):
  Bit = [0]**10
  for j in range(10):
    if (i>>j)&1:
      Bit[j]=1
  count = 0
  for k in range(N):
    op = sum(b&f for b,f in zip(Bit,F[k]))
    count+=P[k][op]
  ans = max(ans,count)

print(ans)

### FIXED CODE ###

N = int(input())
F = [list(map(int,input().split())) for i in range(N)]
P = [list(map(int,input().split())) for i in range(N)]
 
ans = -10**9
for i in range(2**10-1):
  Bit = [1]*10
  for j in range(10):
    if (i>>j)&1:
      Bit[j]=0
  count = 0
  for k in range(N):
    op = sum(b&f for b,f in zip(Bit,F[k]))
    count+=P[k][op]
  ans = max(ans,count)
print(ans)
N = input()
A = list(map(int, input().split()))
INF = 1.0e+100

def f(l, r):
  if r - l == 1:
    return A[l]
  ret = INF
  for i in range(l+1, r):
    lr = f(l, i)
    rr = f(i, r)
    ret = min(ret, lr+rr)
  return ret

print(f(l,r))

### FIXED CODE ###

from functools import lru_cache
N = int(input())
A = list(map(int, input().split()))

INF = 1.0e+100


dp = [[[None, INF] for _ in range(N+1)] for _ in range(N+1)]
for i in range(N):
    dp[i][i+1] = [A[i], 0]

for g in range(2, N+1):
    for l in range(N-g+1):
        r = l + g
        for i in range(l+1, r):
            lv, lc = dp[l][i]
            rv, rc = dp[i][r]
            nc = lv + rv + lc + rc
            if dp[l][r][1] > nc:
                dp[l][r][0] = lv + rv
                dp[l][r][1] = nc

print(dp[0][N][1])
import numpy as np

N = int(input())
# P = np.array(input().split(' '), dtype = int)
P = np.array(list(map(int, input().split(' '))))

# print(N - sum([np.any(P[:i+1] < P[i]) for i in range(N)]))
ar_bool = (P < P.reshape(-1,1))
for i in range(N):
    N -= np.any((ar_bool)[i][:i+1])
print(N)


### FIXED CODE ###

N = int(input())
# P = np.array(input().split(' '), dtype = int)
P = list(map(int, input().split(' ')))

p_min = P[0]
ans = 0
for p in P:
    if p <= p_min:
        p_min = p
        ans += 1
print(ans)
N, ma, mb = map(int, input().split())
a = [0]*N
b = [0]*N
c = [0]*N
NMAX = 10
ABMAX = 10
INF = 100000
for i in range(N):
    a[i], b[i], c[i] = map(int, input().split())
dp = [[[INF]*(NMAX*ABMAX+1)for _ in range(NMAX*ABMAX+1)]for _ in range(N+1)]
dp[0][0][0] = 0
for i in range(N):
    for ca in range(NMAX*ABMAX+1):
        for cb in range(NMAX*ABMAX+1):
            if dp[i][ca][cb] == INF:
                continue
            dp[i+1][ca][cb] = min(dp[i+1][ca][cb], dp[i][ca][cb])
            dp[i+1][ca+a[i]][cb+b[i]
                             ] = min(dp[i+1][ca+a[i]][cb+b[i]], dp[i][ca][cb]+c[i])
ans = INF
for ca in range(1, NMAX*ABMAX+1):
    for cb in range(1, NMAX*ABMAX+1):
        if ca * mb == cb * ma:
            ans = min(ans, dp[N][ca][cb])
print(ans if ans != INF else -1)


### FIXED CODE ###

N, ma, mb = map(int, input().split())
a = [0]*N
b = [0]*N
c = [0]*N
NMAX = 40
ABMAX = 10
INF = 1000000
for i in range(N):
    a[i], b[i], c[i] = map(int, input().split())
dp = [[[INF]*(NMAX*ABMAX+1)for _ in range(NMAX*ABMAX+1)]for _ in range(N+1)]
dp[0][0][0] = 0
for i in range(N):
    for ca in range(NMAX*ABMAX+1):
        for cb in range(NMAX*ABMAX+1):
            if dp[i][ca][cb] == INF:
                continue
            dp[i+1][ca][cb] = min(dp[i+1][ca][cb], dp[i][ca][cb])
            dp[i+1][ca+a[i]][cb+b[i]
                             ] = min(dp[i+1][ca+a[i]][cb+b[i]], dp[i][ca][cb]+c[i])
ans = INF
for ca in range(1, NMAX*ABMAX+1):
    for cb in range(1, NMAX*ABMAX+1):
        if ca * mb == cb * ma:
            ans = min(ans, dp[N][ca][cb])
print(ans if ans != INF else -1)
n =6;
a=[input() for i in range(n)]

k = a[-1];
ans = "Yay!";

for i in range(n-1):
	#print("n-i-1: " + str(n-i-1));
  	if k < a[n-i-1] - a[i]:
  		ans = ":( ";
  		break;

print ans;

### FIXED CODE ###

n = 6;
a = [input() for i in range(n)];
 
k = a[-1];
ans = "Yay!";
 
for i in range(n-1):
  for j in reversed(range(n-1)):
    if k < a[i] - a[j]:
      ans = ":( ";
      break;
print ans;
import bisect

def dfs(v):
  pos=bisect.bisect_left(dp,arr[v])
  changes.append((pos,dp[pos]))
  dp[pos]=arr[v]
  ans[v]=bisect.bisect_left(dp,10**18)
  for u in g[v]:
    if checked[u]==0:
      checked[u]=1
      dfs(u)
  pos,val=changes.pop()
  dp[pos]=val

n=int(input())
arr=[0]+list(map(int,input().split()))
g=[[] for _ in range(n+1)]
for _ in range(n-1):
  a,b=map(int,input().split())
  g[a].append(b)
  g[b].append(a)
ans=[0]*(n+1)
checked=[0]*(n+1)
checked[1]=1
dp=[10**18 for _ in range(n+1)]
changes=[]
dfs(1)
for i in range(1,n+1):
  print(ans[i])

### FIXED CODE ###

import bisect
import sys
sys.setrecursionlimit(10**7)

def dfs(v):
  pos=bisect.bisect_left(dp,arr[v])
  changes.append((pos,dp[pos]))
  dp[pos]=arr[v]
  ans[v]=bisect.bisect_left(dp,10**18)
  for u in g[v]:
    if checked[u]==0:
      checked[u]=1
      dfs(u)
  pos,val=changes.pop()
  dp[pos]=val

n=int(input())
arr=[0]+list(map(int,input().split()))
g=[[] for _ in range(n+1)]
for _ in range(n-1):
  a,b=map(int,input().split())
  g[a].append(b)
  g[b].append(a)
ans=[0]*(n+1)
checked=[0]*(n+1)
checked[1]=1
dp=[10**18 for _ in range(n+1)]
changes=[]
dfs(1)
for i in range(1,n+1):
  print(ans[i])
n=int(input())
s = list(input() for _ in range(n))
m=int(input())
t = list(input() for _ in range(m))

def list_difference(s,t):
    l = s.copy()
    for value in t:
        if value in l:
            l.remove(value)

    return l
l=list_difference(s,t)
l1=Counter(l)
print(l1.most_common()[0][1])

### FIXED CODE ###

from collections import Counter
n=int(input())
s = [input() for _ in range(n)]
m=int(input())
t = [input() for _ in range(m)]

def list_difference(s,t):
    l = s.copy()
    for value in t:
        if value in l:
            l.remove(value)
    return l
l=list_difference(s,t)
l1=Counter(l)
if len(l)>0:print(l1.most_common()[0][1])
else:print(0)
s = list(input())
for i in range(len(s)):
    if i % 2 == 0 and s[i] == "L":
        print("No")
        return
    if i % 2 != 0 and s[i] == "R":
        print("No")
        return
print("Yes")

### FIXED CODE ###

s = list(input())
for i in range(len(s)):
    if i % 2 == 0 and s[i] == "L":
        print("No")
        exit()
    if i % 2 != 0 and s[i] == "R":
        print("No")
        exit()
print("Yes")
A,B=input().split()
poker=['2','3','4','5','6','7','8','9','10','11','12','1']
if poker.index(A)<poker.index(B):
    print('Bob')
elif  poker.index(A)>poker.index(B):
    print('Alice')
else:
    print('Draw')

### FIXED CODE ###

A,B=input().split()
poker=['2','3','4','5','6','7','8','9','10','11','12','13','1']
if poker.index(A)<poker.index(B):
    print('Bob')
elif poker.index(A)>poker.index(B):
    print('Alice')
else:
    print('Draw')
'''
Sample Input 1 

5
2 6 1 4 5
Sample Output 1 

YES
'''
lens = int(input())
arrs = [int(x) for x in input(),split()]
print(["NO", "YES"][len(arrs) == len(set(arrs))])

### FIXED CODE ###

'''
Sample Input 1

5
2 6 1 4 5
Sample Output 1

YES
'''
lens = int(input())
arrs = [int(x) for x in input().split()]
print(["NO", "YES"][len(arrs) == len(set(arrs))])
import numpy as np
n=int(input())
a=[int(input()) for i in range(n)]
m=max(a)
for i in range(n):
  if a[i]!=m:
    print(m)
  else:
    print(max(a[:n].extend(a[n+1:])))

### FIXED CODE ###

import numpy as np
n=int(input())
a=[int(input()) for i in range(n)]
a_=sorted(a)
m=max(a)
for i in range(n):
  if a[i]!=m:
    print(m)
  else:
    print(a_[-2])
N = int(input())

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

ones = [0] * 60
m = 10 ** 9 + 7

for Ai in A:
    for digit in range(len(bin(Ai) - 2)):
        ones[digit] += ((Ai >> digit) & 1)

res = 0
for i, num in enumerate(ones):
    res = (res + (1 << i) * num * (N - num)) % m

print(res)


### FIXED CODE ###

N = int(input())

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

num = [[0, 0] for _ in range(60)]

for Ai in A:
    for digit in range(60):
        if (Ai >> digit) & 1:
            num[digit][1] += 1
        else:
            num[digit][0] += 1

res = 0
for i, p in enumerate(num):
    res += (1 << i) * p[0] * p[1]

m = 10 ** 9 + 7
print(res % m)