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

from math import factorial
import bisect

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

a.sort()

def comb(x,y):
    return factorial(x) // factorial(y) // factorial(x-y)

count = 0
max1 = 0
ans = [0,0]

for i in a:
    j = bisect.bisect_left(a,i/2)
    if j-1 >= 0:
        if max1 < comb(i,a[j-1]) and i != a[j-1]:
            max1 = comb(i,a[j-1])
            ans = [i,a[j-1]]

    if j >= 0:
        if max1 < comb(i,a[j]) and i != a[j]:
            max1 = comb(i,a[j])
            ans = [i,a[j]]
    if j+1 < n:
        if i >= a[j+1]:
            if max1 < comb(i,a[j+1]) and i != a[j+1]:
                max1 = comb(i,a[j+1])
                ans = [i,a[j+1]]

print(ans[0], ans[1])


### FIXED CODE ###

import bisect

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

a.sort()

idx = bisect.bisect_left(a,a[-1]/2)

if idx == 0:
    print(a[-1],a[idx])
else:
    x,y = a[idx-1],a[idx]
    if y - a[-1]/2 < a[-1]/2 - x:
        print(a[-1],y)
    else:
        print(a[-1],x)
### BUGGY CODE ###

N=int(input())
Sister=[int(input()) for i in range(N)]
set_Sister=set(Sister)
Paper=0
for i in set_Sister:
  if Sister.count(i)%2==1:
    Paper+=1
print(Paper)

### FIXED CODE ###

N=int(input())
Sister={}
Paper=0
for i in range(N):
  index=int(input())
  if index not in Sister:
    Sister[index]=1
  else:
    Sister[index]+=1
for i in Sister:
  if Sister[i]%2==1:
    Paper+=1
print(Paper)
### BUGGY CODE ###

n=int(input())
l=input().split()
for i in range(1,n):
    print(l.count(str(i)))
print(0)


### FIXED CODE ###

n=int(input())
l=list(map(int,input().split()))
m=[0]*n
for i in l:
    m[i-1]+=1
for j in range(n):
    print(m[j])
### BUGGY CODE ###

from copy import deepcopy

def getval():
    r,c,k = map(int,input().split())
    item = [[0 for i in range(c)] for i in range(r)]
    for i in range(k):
        ri,ci,vi = map(int,input().split())
        item[ri-1][ci-1] = vi
    return r,c,k,item

def main(r,c,k,item):
    #DP containing the information of max value given k items picked in i,j
    prev = [[0 for i in range(4)]]
    inititem = item[0][0]
    prev[0] = [0,inititem,inititem,inititem]
    for i in range(1,r):
        initval = prev[i-1][3]
        temp = []
        cur = item[i][0]
        for j in range(4):
            temp.append(initval)
        for j in range(1,4):
            temp[j] += cur
        prev.append(temp)

    for j in range(1,c):
        init = deepcopy(prev[0])
        for i in range(1,4):
            init[i] = max(prev[0][i],prev[0][i-1]+item[0][j])
        curcol = [init]
        for i in range(1,r):
            cur = item[i][j]
            left = curcol[-1]
            down = prev[i]
            temp = [max(left[3],down[0])]
            for k in range(1,4):
                temp.append(max(max(left[3],down[k-1])+cur,down[k]))
            curcol.append(temp)
        prev = deepcopy(curcol)
            
    print(max(prev[-1]))
           
if __name__=="__main__":
    r,c,k,item = getval()
    main(r,c,k,item) 

### FIXED CODE ###

from copy import deepcopy

def getval():
    r,c,k = map(int,input().split())
    item = [[0 for i in range(c)] for i in range(r)]
    for i in range(k):
        ri,ci,vi = map(int,input().split())
        item[ri-1][ci-1] = vi
    return r,c,k,item

def main(r,c,k,item):
    #DP containing the information of max value given k items picked in i,j
    prev = [[0 for i in range(4)]]
    inititem = item[0][0]
    prev[0] = [0,inititem,inititem,inititem]
    for i in range(1,r):
        initval = prev[i-1][3]
        temp = []
        cur = item[i][0]
        for j in range(4):
            temp.append(initval)
        for j in range(1,4):
            temp[j] += cur
        prev.append(temp)

    for j in range(1,c):
        init = deepcopy(prev[0])
        for i in range(1,4):
            init[i] = max(prev[0][i],prev[0][i-1]+item[0][j])
        curcol = [init]
        for i in range(1,r):
            cur = item[i][j]
            left = curcol[-1]
            down = prev[i]
            temp = [max(left[3],down[0])]
            for k in range(1,4):
                temp.append(max(max(left[3],down[k-1])+cur,down[k]))
            curcol.append(temp)
        prev = curcol
            
    print(max(prev[-1]))
           
if __name__=="__main__":
    r,c,k,item = getval()
    main(r,c,k,item)
### BUGGY CODE ###

from collections import Counter

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

for i in range(n):
    ans = 0
    c[a[i]] -= 1
    for v in c.values():
        ans += v*(v-1)//2
    c[a[i]] += 1
    print(ans)
    

### FIXED CODE ###

from collections import Counter

n = int(input())
a = list(map(int, input().split()))
c = dict(Counter(a))
ans = 0
for v in c.values():
    ans += v*(v-1)//2
for i in range(n):
    print(ans-c[a[i]]+1)
### BUGGY CODE ###

from collections import deque

line1 = input()
n, k = [int(num) for num in line1.split(" ")]
line2 = input()
h = [int(num) for num in line2.split(" ")]

d = deque([0], k)

for i in range(1, len(h)):
    min_cost = float("inf")
    for j,cost in enumerate(reversed(d)):
        steps_taken = j+1
        if i-steps_taken < 0: break
        step_cost = abs(h[i]-h[i-steps_taken])
        min_cost = min(min_cost, cost + abs(h[i]-h[i-steps_taken]))
        if step_cost == 0: break
    d.append(min_cost)

print(d[-1])

### FIXED CODE ###

from collections import deque

line1 = input()
n, k = [int(num) for num in line1.split(" ")]
line2 = input()
h = [int(num) for num in line2.split(" ")]

d = deque([0], k)

for i in range(1, len(h)):
    min_cost = float("inf")
    for j,cost in enumerate(reversed(d)):
        steps_taken = j+1
        if i-steps_taken < 0: break
        step_cost = abs(h[i]-h[i-steps_taken])
        min_cost = min(min_cost, cost + abs(h[i]-h[i-steps_taken]))
        if step_cost == 0: break
    d.append(min_cost)

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

l = input()
mod = 10**9+7
L = len(l)

def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod) 
  
def comb(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

def f(x):
  res = 0
  for i in range(x+1):
    res += pow(2,x-i,mod)*comb(x,i,mod)%mod
    res %= mod
  return res
  
ans = f(L)
cnt = 0
for i,li in enumerate(l):
  if li == '0':
    ans -= f(L-1-i)*pow(2,cnt+1,mod)%mod
    ans %= mod
  else:
    cnt += 1
    
print(ans%mod)

### FIXED CODE ###

l = input()
mod = 10**9+7
L = len(l)

ans = pow(3,L,mod)
cnt = 0
for i,li in enumerate(l):
  if li == '0':
    ans -= pow(3,L-1-i,mod)*pow(2,cnt+1,mod)
    ans %= mod
  else:
    cnt += 1
    
print(ans%mod)
### BUGGY CODE ###

"""
青木君は任意の整数 x

に対し、以下の操作を行うことができます。

操作: x
を x と K

の差の絶対値で置き換える。

整数 N
の初期値が与えられます。この整数に上記の操作を 0 回以上好きな回数行った時にとりうる N

の最小値を求めてください。
制約
"""
n,k=map(int,input().split())
"""if n>k:
    x=n-k
else:
    x=n
"""
x=n
r=min(x,abs(x-k))
for ii in range(max(k,x)):
    x=min(x,abs(x-k))
#    print(r,x,abs(x-k))
    if r==min(x,abs(x-k)):
        break
    else:
        r=min(x,abs(x-k))

print(r)

### FIXED CODE ###

"""
青木君は任意の整数 x

に対し、以下の操作を行うことができます。

操作: x
を x と K

の差の絶対値で置き換える。

整数 N
の初期値が与えられます。この整数に上記の操作を 0 回以上好きな回数行った時にとりうる N

の最小値を求めてください。
制約
"""
n,k=map(int,input().split())
x=n
if k==x:
    r=0
elif k>x:
    r=min(x,(k-x))
else:
    if (x-k)>=k:
        r=min(k-(x-k)%k,(x-k)%k)
    else:
        r=min(k-k%(x-k),k%(x-k))
print(r)
### BUGGY CODE ###

def inp():exec('global inppp\ninpmoto,inppp=input().split(),[]\nfor i in inpmoto:\n try:inppp.append(int(i))if float(i).is_integer()else inppp.append(float(i));\n except:\n  try:inppp.append(str(i))\n  except:print("error in inp")');return inppp[0]if len(inppp)==1else list(inppp)
a, b = inp()
c = inp()
if type(c) == int:
    c = [c]
itta = []
mati = 1
i = 0
while True:
    if mati in itta:
        saisyo = mati
        break
    else:
        itta.append(mati)
        mati = c[mati-1]
        i += 1
risuto = []
while True:
    if mati in risuto:
        break
    else:
        risuto.append(mati)
        mati = c[mati-1]
if b <= i-1:
    print(itta[b])
else:
    print(risuto[(b-i) % len(risuto)])

### FIXED CODE ###

a, b = list(map(int, input().split()))
c = list(map(int, input().split()))
itta2 = set([])
mati = 1
i = 0
itta = []
while True:
    if mati in itta2:
        saisyo = mati
        break
    else:
        itta2.add(mati)
        itta.append(mati)
        mati = c[mati-1]
        i += 1
risuto2 = set([])
risuto = []

while True:
    if mati in risuto2:
        break
    else:
        risuto2.add(mati)
        risuto.append(mati)
        mati = c[mati-1]
if b <= i-1:
    print(itta[b])
else:
    print(risuto[(b-i) % len(risuto)])
### BUGGY CODE ###

n=int(input())
a=[int(_) for _ in input().split()]
ans=0
for i in range(n):
    t=a[i]
    for j in range(i+t,n):
        ans+=a[j]==j-i-t
print(ans)

### FIXED CODE ###

import collections
n=int(input())
a=[int(_) for _ in input().split()]
l=[a[i]+i for i in range(n)]
r=[i-a[i] for i in range(n)]
c=collections.Counter(r)
ans=0
for i in range(n):ans+=c[l[i]]
print(ans)
### BUGGY CODE ###

N = int(input())
A = [int(input()) for _ in range(N)]
for i in range(N):
  print(max(A[:i] + A[i+1:]))

### FIXED CODE ###

N = int(input())
A = [int(input()) for _ in range(N)]

max_val = max(A)
count = A.count(max_val)

subset = list(set(A))
if len(subset) > 1:
  subset.remove(max_val)
  max_val_2 = max(subset)

for i, num in enumerate(A):
  if num < max_val:
    print(max_val)
  else:
    if count > 1:
      print(max_val)
    else:
      print(max_val_2)
### BUGGY CODE ###

from sys import stdin
from random import randint
from time import time
input = lambda: stdin.readline().rstrip()
start = time()
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
b.reverse()
ok = 0
t = time() - start
while t < 1.9:
    cnt = 0
    for i in range(n):
        if a[i] == b[i]:
            rng = randint(0, n - 1)
            b[i], b[rng] = b[rng], b[i]
            cnt += 1
    if cnt == 0:
        ok = 1
        break
    t = time() - start
if ok == 1:
    print("Yes")
    print(*b)
else:
    print("Yes")


### FIXED CODE ###

from sys import stdin
from random import randint
from time import time
input = lambda: stdin.readline().rstrip()
start = time()
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
b.reverse()
ok = 0
t = time() - start
while t < 1.8:
    cnt = 0
    for i in range(n):
        if a[i] == b[i]:
            rng = randint(0, n - 1)
            b[i], b[rng] = b[rng], b[i]
            cnt += 1
    if cnt == 0:
        ok = 1
        break
    t = time() - start
if ok == 1:
    print("Yes")
    print(*b)
else:
    print("No")
### BUGGY CODE ###

MOD = 10 ** 9 + 7

def kaijo(n):
    k = 1
    for i in range(1, n + 1):
        k *= i % MOD
    return k

n, m = map(int, input().split())
if n == m:
    print((kaijo(n) ** 2 * 2) % MOD)
elif abs(n - m) > 1:
    print(0)
else:
    if n < m:
        print((kaijo(n) ** 2 * m) % MOD)
    else:
        print((kaijo(m) ** 2 * n) % MOD)

### FIXED CODE ###

MOD = 10 ** 9 + 7

def kaijo(n):
    k = 1
    for i in range(1, n + 1):
        k = k * i % MOD
    return k

n, m = map(int, input().split())
if n == m:
    print((kaijo(n) ** 2 * 2) % MOD)
elif abs(n - m) > 1:
    print(0)
else:
    if n < m:
        print((kaijo(n) ** 2 * m) % MOD)
    else:
        print((kaijo(m) ** 2 * n) % MOD)
### BUGGY CODE ###

from operator import mul
from functools import reduce

[n,k] = map(int, input().split(' '))
A = list(map(int, input().split(' ')))

def hyoka(j,p,b_point):
  if j == k:
    point = reduce(mul, A[0:j])
    return point
  else:
    point = b_point/A[j-k-1]*p
    
  if b_point < point:
    print('Yes')
  else:
    print('No')
  return point
b_point = 0
for i,p in enumerate(A):
  if i+1 < k:
    continue
  result = hyoka(i+1,p,b_point)
  if result > 0:
  	b_point = result


### FIXED CODE ###

[n,k] = map(int, input().split(' '))
A = list(map(int, input().split(' ')))

for i in range(k,n):
  if A[i-k]<A[i]:
    print('Yes')
  else:
    print('No')
### BUGGY CODE ###

N = int(input()) # 各リストの数
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=False)
A.append(float('inf'))
B.sort(reverse=False)

# A > B > Cである組み合わせの数を求める
count = 0
for ic in range(N):
    bottom_a = 0
    for ib in range(N):
        if B[ib] >= C[ic]:
            break
        
        top_a = N
        count_a = 0
        while top_a >= bottom_a:
            middle_a = (top_a + bottom_a) // 2

            if A[middle_a] == B[ib]:
                count_a = middle_a - 1
                break
            if A[middle_a] < B[ib] and B[ib] < A[middle_a + 1]:
                count_a = middle_a
                break
            if A[middle_a] > B[ib]:
                top_a = middle_a
            if A[middle_a] < B[ib]:
                bottom_a = middle_a + 1

        count += count_a + 1
        bottom_a = count_a

print(count)




### FIXED CODE ###

import bisect
import itertools

N = int(input()) # それぞれのパーツの数
A = list(map(int, input().split())) # 小さい
B = list(map(int, input().split())) # 中くらい
C = list(map(int, input().split())) # 大きい

# Cは並び替え不要
A.sort()
B.sort()

# Bの各要素でAを二分探索して返ってきたindexを先に保有しておく
b_counts = [0] * N
for i in range(N):
    b_count = bisect.bisect_left(A, B[i])
    b_counts[i] = b_count

cumsum_b_counts = list(itertools.accumulate(b_counts))
cumsum_b_counts = [0] + cumsum_b_counts

# Cの各要素でBを二分探索。上記で保有しておいたb_countsを活用する
total = 0
for c in C:
    count = bisect.bisect_left(B, c)
    total += cumsum_b_counts[count]

print(total)
### BUGGY CODE ###

import math

MOD = 10**9+7


def make_combination_table(n):
    result = []
    for i in range(n):
        result.append(math.factorial(i))
    return result


def mod_combination(n, r, table):
    if r > n:
        return 0
    return table[n] // (table[n - r] * table[r]) % MOD


def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    c_table = make_combination_table(n)
    ans = 0
    a.sort()
    for i in range(n):
        ans = (ans + a[i] * mod_combination(i, k-1, c_table)) % MOD

    a.sort(reverse=True)
    for i in range(n):
        ans = (ans - a[i] * mod_combination(i, k-1, c_table)) % MOD

    print(ans)


main()


### FIXED CODE ###

import math

MOD = 10**9+7


def make_combination_table(n):
    fact = [1]
    for i in range(1, n+1):
        fact.append(fact[i-1] * i % MOD)

    ifact = [0] * (n+1)
    ifact[n] = pow(fact[n], MOD-2, MOD)
    for i in range(n, 0, -1):
        ifact[i-1] = ifact[i] * i % MOD
    return (fact, ifact)


def mod_combination(n, r, table):
    if r > n:
        return 0
    return table[0][n] * table[1][n - r] * table[1][r] % MOD


def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    c_table = make_combination_table(n)

    a.sort()
    a_max = 0
    for i in range(n):
        a_max += a[i] * mod_combination(i, k-1, c_table) % MOD

    a.sort(reverse=True)
    a_min = 0
    for i in range(n):
        a_min += a[i] * mod_combination(i, k-1, c_table) % MOD

    print((a_max - a_min) % MOD)


main()
### BUGGY CODE ###

n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
bc=[list(map(int,input().split()))[::-1]for _ in range(m)]+[[0,1000000000000]]
bc.sort(reverse=1)
t=[]
for c,b in bc:
  for _ in range(b):
    t.append(c)
    if len(t)==n:break
ans=0
for i in range(n):ans+=max(a[i],t[i])
print(ans)

### FIXED CODE ###

from collections import deque
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
a=deque(a)
x=[]
for i in range(m):x.append(list(map(int,input().split()))[::-1])
x.sort(reverse=1)
for i,j in x:
  for k in range(j):
    if i<=a[0]:print(sum(a));exit()
    a.popleft();a.append(i)
print(sum(a))
### BUGGY CODE ###

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

from bisect import bisect_left, bisect_right

def main():
    N = int(input())
    L = list(map(int, input().split()))
    L.sort()
    ret = 0
    for a in range(N-2):
        for b in range(a+1,N-1):
#            a<b+c => a-b<c
#            b<c+a => b-a<c
#            c<a+b
# b-a<c<a+b
            rr = bisect_right(L[b+1:], L[a]+L[b]-1)
            ll = 0
            ret += rr - ll

    print(ret)

if __name__ == '__main__':
    main()

### FIXED CODE ###

from bisect import bisect
N = int(input())
L = list(map(int, input().split()))
L.sort()
ret = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        ret += bisect(L,L[i]+L[j]-1)-j-1
print(ret)
### BUGGY CODE ###

import collections
n = int(input())
words = []
for i in range(n):
  words.append(input())
c = collections.Counter(words)
max_w = []
for i in c.most_common():
  if i[1]==c.most_common()[0][1]:
    max_w.append(i[0])
max_w.sort()
[print(j) for j in max_w]


### FIXED CODE ###

import collections
n = int(input())
words = []
[words.append(input()) for i in range(n)]
c = collections.Counter(words)
cc = c.most_common()
max_w = []
for i in cc:
  if i[1]==cc[0][1]:
    max_w.append(i[0])
max_w.sort()
[print(j) for j in max_w]
### BUGGY CODE ###

def func():
    return

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

for i in range(n-1):
    for j in range(i+1, n):
        if a[i] == a[j]:
            print("NO")
            exit()

print("YES")

### FIXED CODE ###

def func():
    return

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

ascA = sorted(a)
for i in range(n-1):
    if ascA[i] == ascA[i+1]:
        print("NO")
        exit()

'''
for i in range(n-1):
    for j in range(i+1, n):
        if a[i] == a[j]:
            print("NO")
            exit()
'''
'''
ans = [0]*(max(a)+1)
for ida in a:
    if ans[ida] > 0:
        print("NO")
        exit()
    ans[ida] += 1
'''

print("YES")
### BUGGY CODE ###

n,x = -1,-1
table = []
while n != 0 or x != 0:
  n,x = (int(x) for x in input().split())
  table.append([n,x])

for t in table:
  n = t[0]
  x = t[1]
  if n == 0 and x == 0:
    break
  i = 1
  s = 0
  while i < n:
    if x - i > n + (n - 1):
      continue
    else:
      j = i + 1
      while j < n:
        if x - i - j <= n and x - i - j > j:
#          print (str(i) + "," + str(j) + "," + str(x - i - j))
          s += 1
        j += 1
    i += 1
  print (s)


### FIXED CODE ###

n,x = -1,-1
table = []
while n != 0 or x != 0:
  n,x = (int(x) for x in input().split())
  table.append([n,x])

for t in table:
  n = t[0]
  x = t[1]
  if n == 0 and x == 0:
    break
  i = 1
  s = 0
  while i < n:
    #print (i)
    if x - i > n + (n - 1):
      i += 1
      continue
    else:
      j = i + 1
      while j < n:
        #print (str(i) + "," + str(j) + "," + str(x - i - j))
        if x - i - j <= n and x - i - j > j:
          s += 1
        j += 1
      i += 1
  print (s)
### BUGGY CODE ###

from collections import defaultdict
def dp(H, N, a, b):
  d = defaultdict(lambda: INF)
  d[0] = 0
  max_a = max(a)
  for h in range(1, H + max_a):
    d[h] = min([d[h - a[i]] + b[i] for i in range(N)])
  return min([d[H + h] for h in range(max_a)])

INF = 10 ** 10
H, N = map(int, input().split())
a = [0 for _ in range(N)]
b = [0 for _ in range(N)]
for i in range(N):
  ai, bi = map(int, input().split())
  a[i] = ai
  b[i] = bi
print(dp(H, N, a, b))

### FIXED CODE ###

def dp(H, N, ab):
  max_a = max([ab[i][0] for i in range(N)])
  d = [INF for _ in range(H + max_a)]
  d[0] = 0
  for h in range(1, H + max_a):
    d[h] = min(d[h - a] + b for a, b in ab)
  return min(d[H:])
INF = 10 ** 10
H, N = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(N)]
print(dp(H, N, ab))
### BUGGY CODE ###

N,K = map(int, input().split())
d = []
for i in range(K):
    L, R = map(int, input().split())
    d.append(L)
    d.append(R)
a=[0]*(N+1)
b=[0]*(N+1)
a[1]=1
b[1]=1
for i in range(2,N+1):
    t=0
    for j in range(K):
        if i-d[2*j]>0:
            t+=b[i-d[2*j]]
        if i-d[2*j+1]-1>0:
            t-=b[i-d[2*j+1]-1]
    a[i]=t
    b[i]=b[i-1]+a[i]
print(a[N]%998244353)


### FIXED CODE ###

N,K = map(int, input().split())
d = [0]*2*K
for i in range(K):
    d[2*i], d[2*i+1] = map(int, input().split())
a=[0]*(N+1)
b=[0]*(N+1)
a[1]=1
b[1]=1
for i in range(2,N+1):
    t=0
    for j in range(K):
        if i-d[2*j]>0:
            t+=b[i-d[2*j]]
        if i-d[2*j+1]-1>0:
            t-=b[i-d[2*j+1]-1]
    a[i]=t
    b[i]=(b[i-1]+a[i])%998244353
print(a[N]%998244353)
### BUGGY CODE ###

MOD = 10**9+7
n = int(input())
a = list(map(int, input().split()))
ans = 0
for b in range(61):
	zero, one = 0, 0
	for x in a:
		if (x>>b)&1:
			one += 1
		else:
			zero += 1
	ans += zero*one*(1<<b)
	ans %= MOD
print(ans)

### FIXED CODE ###

MOD = 10**9+7
n = int(input())
a = list(map(int, input().split()))
ans = 0
for b in range(61):
	zero, one = 0, 0
	for x in a:
		if (x>>b)&1:
			one += 1
		else:
			zero += 1
	ans += zero*one*(1<<b)
	ans %= MOD
print(ans)
### BUGGY CODE ###

from collections import Counter, deque

N = int(input())
S = list(input())
s_c = Counter(S)

a = s_c["R"] * s_c["B"] * s_c["G"]

for i in range(N):
    for j in range(i + 1, N):
        for _ in range(j + 1, N):
            if (S[i] != S[j] and S[i] != S[_] and S[j] != S[_]) and \
                not (j - i != _ - j):
                a -= 1
print(a)

### FIXED CODE ###

from collections import Counter

N = int(input())
S = list(input())
s_c = Counter(S)

a = s_c["R"] * s_c["B"] * s_c["G"]

for i in range(N):
    for j in range(i + 1, N):
        k = 2 * j - i
        if k >= N:
            break
        elif (S[i] != S[j] and S[i] != S[k] and S[j] != S[k]) and \
            not (j - i != k - j):
            a -= 1
print(a)
### BUGGY CODE ###

import bisect

n = int(input())
a_li = list(map(int, input().split()))
b_li = list(map(int, input().split()))
c_li = list(map(int, input().split()))

a_li.sort()
b_li.sort()
c_li.sort()

if a_li[0] >= b_li[-1]:
    print(0)
    exit()
    
ans = 0

for i in a_li:
    s = bisect.bisect_right(b_li, i)
    
    for j in b_li[s:]:
        t = bisect.bisect_right(c_li, j)
        ans += len(c_li[t:])
        
print(ans)

### FIXED CODE ###

import bisect

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

a.sort()
b.sort()
c.sort()

ans = 0

for middle in b:
    tmp1 = bisect.bisect_left(a, middle)
    tmp2 = bisect.bisect_right(c, middle)
    ans += tmp1 * (n - tmp2)

print(ans)