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

n, a = map(int, input().split())
x = list(map(lambda q: int(q) - a, input().split()))
num = 0
for i in range(1, 1 << n):
    s = 0
    for j in range(n):
        if 1 << j & i:
            s += x[j]
    if s == 0:
        num += 1

print(num)

### FIXED CODE ###

n, a = map(int, input().split())
x = list(map(lambda q: int(q) - a, input().split()))
X = max(max(x), a)
N = 2 * n * X
dp = [[0] * (N + 1) for i in range(n + 1)]
dp[0][n * X] = 1
for i in range(1, n + 1):
    for j in range(N + 1):
        if j - x[i - 1] < 0 or j - x[i - 1] > N:
            dp[i][j] = dp[i - 1][j]
        elif j - x[i - 1] <= N:
            dp[i][j] = dp[i - 1][j] + dp[i - 1][j - x[i - 1]]

print(dp[n][n * X] - 1)
### BUGGY CODE ###

from itertools import combinations

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

ans = 0
for i in range(1, N+1):
    tmp = 0
    lst = list(combinations(S, i))
    for l in lst:
        if len(set(l)) == len(l):
            tmp += 1
    ans += tmp
print(ans)

### FIXED CODE ###

N = int(input())
S = input()
alphabet = "abcdefghijklmnopqrstuvwxyz"

ans = 1
for char in alphabet:
    count_char = S.count(char) + 1
    ans *= count_char
ans -= 1
ans %= (10**9+7)

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

#!/usr/bin/env python3
import sys


def solve(N: int, K: int, A: "List[int]"):

    for k in range(K):
        B = [0] * N

        for i in range(N):
            l = max(0, i - A[i])
            r = i + A[i]

            B[l] += 1
            if r + 1 < N:
                B[r + 1] -= 1

        for i in range(1, N):
            B[i] += B[i - 1]

        A = B.copy()
        if sum(A) == N*N:
            break
    print(*A)

    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, A)


if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys


def solve(N: int, K: int, A: "List[int]"):

    for k in range(K):
        B = [0] * N

        for i in range(N):
            l = max(0, i - A[i])
            r = i + A[i]

            B[l] += 1
            if r + 1 < N:
                B[r + 1] -= 1

        for i in range(1, N):
            B[i] += B[i - 1]

        A = B.copy()
        if sum(A) == N*N:
            break
    print(*A)

    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, A)


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

n=int(input())
L=list(reversed(sorted(map(int,input().split()))))
ans=0
for i in range(n-2):
    a=L[i]
    for j in range(i+1,n-1):
        b=L[j]
        for k in range(j+1,n):
            c=L[k]
            if a<b+c:
                ans+=1
            else:
                break
print(ans)

### FIXED CODE ###

n=int(input())
L=list(sorted(map(int,input().split())))
ans=0

for i in range(n-2):
    a=L[i]
    for j in range(i+1,n-1):
        b=L[j]
        high=n-1
        low=j+1
        if L[high]<a+b:
            ans+=n-j-1
            continue
        if L[low]>=a+b:
            continue
        while high-low>1:
            now=(high+low)//2
            c=L[now]
            if c<a+b:
                low=now
            else:
                high=now
        ans+=low-j
print(ans)
### BUGGY CODE ###

s = input()

s_work = s
s_stack = []
while len(s_work) > 0:
    if s_work.startswith("dream"):
        s_stack.append("dream")
        s_work = s_work[len("dream"):]
    elif s_work.startswith("erase"):
        s_stack.append("erase")
        s_work = s_work[len("erase"):]
    else:
        if len(s_stack) == 0 or s_stack[-1].endswith("er"):
            print("NO")
            exit()
        s_work = s_stack.pop() + s_work
        if s_work.startswith("dreamer"):
            s_stack.append("dreamer")
            s_work = s_work[len("dreamer"):]
        elif s_work.startswith("eraser"):
            s_stack.append("eraser")
            s_work = s_work[len("eraser"):]
        else:
            print("NO")

print("YES")


### FIXED CODE ###

s = input()

s_work = s
target_list = ["dream", "dreamer", "erase", "eraser"]

while len(s_work) > 0:
    has_changed = False
    for target in target_list:
        if s_work.endswith(target):
            s_work = s_work[0:-len(target)]
            has_changed = True
            break
    if not has_changed:
        print("NO")
        exit()

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

import sys
sys.setrecursionlimit(10 ** 7)

N,Q = map(int,input().split())
AB = [[x for x in map(int,input().split())] for _ in range(N-1)]
PX = [[x for x in map(int,input().split())] for _ in range(Q)]

graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)

cnt = [0]*N
for p,x in PX:
    cnt[p-1] += x

def dfs(v,parent):
    for w in graph[v]:
        if w != parent:
             cnt[w-1] += cnt[v-1]
             dfs(w,v)

for i in graph[1]:
    cnt[i-1] += cnt[0]
    dfs(i,1)

print(*cnt)

### FIXED CODE ###

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

N,Q = map(int,input().split())
AB = [[int(x) for x in input().split()] for _ in range(N-1)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]

graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)

value = [0] * (N+1)
for p,x in PX:
    value[p] += x

def dfs(v,parent,add):
    value[v] += add
    for x in graph[v]:
        if x == parent:
            continue
        dfs(x,v,value[v])

dfs(1,0,0)

answer = ' '.join(map(str,value[1:]))
print(answer)
### BUGGY CODE ###

#!/usr/bin/python

import math
import sys

def is_prime(n):
    if n == 1:
        return False

    for i in xrange(2, int(math.sqrt(n)) + 1):
        if n % i == 0:
            return False
    return True

def main(argv):
    primes = {}
    for i in xrange(2, 10000):
        if is_prime(i):
            primes[i] = True

    line = sys.stdin.readline()
    while line:
        Q = int(line.rstrip("\n"))
        for i in xrange(Q):
            l, r = map(
              lambda i: int(i), sys.stdin.readline().rstrip("\n").split(" "))

            counter = 0
            while l <= r:
                if l in primes and (l + 1) / 2 in primes:
                    counter += 1
                l += 2
            print counter

        line = sys.stdin.readline()

if __name__ == "__main__":
    main(sys.argv)

### FIXED CODE ###

#!/usr/bin/python

import math
import sys

def is_prime(n):
    if n == 1:
        return False

    for i in xrange(2, int(math.sqrt(n)) + 1):
        if n % i == 0:
            return False
    return True

def main(argv):
    primes = [False]
    for i in xrange(1, 100000 + 1):
        primes.append(is_prime(i))

    counter = 0
    results = [0]
    for i in xrange(1, 100000 + 1):
        if i % 2 == 0:
            results.append(counter)
            continue

        if primes[i] and primes[(i + 1) / 2]:
            counter += 1
        results.append(counter)

    line = sys.stdin.readline()
    while line:
        Q = int(line.rstrip("\n"))
        for i in xrange(Q):
            l, r = map(
              lambda i: int(i), sys.stdin.readline().rstrip("\n").split(" "))

            print results[r] - results[l - 1]

        line = sys.stdin.readline()

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

import itertools
N,M = [int(i) for i in input().split(' ')]

x = []

for i in range(N):
    x.append([int(i) for i in input().split(' ')])

ans = 0
p = list(itertools.permutations(x,M));
for i in p:
    A=0
    B =0
    C=0
    for j in range(M):
        A += i[j][0]
        B += i[j][1]
        C += i[j][2]

    a = abs(A) + abs(B) + abs(C)
    ans = max(a,ans)

#print(p)
print(ans)
   


### FIXED CODE ###

import itertools
N,M = [int(i) for i in input().split(' ')]

x = []

for i in range(N):
    x.append([int(i) for i in input().split(' ')])
tab = [0]*N
ans = 0
#p = list(itertools.permutations(x,M));
for S in [[1,1,1],[1,1,-1],[1,-1,1],[1,-1,-1],[-1,1,1],[-1,1,-1],[-1,-1,1],[-1,-1,-1]]:
    for j in range(N):
        a = 0
        a += x[j][0]*S[0]
        a += x[j][1]*S[1]
        a += x[j][2]*S[2]
        tab[j] = a
    tab.sort()
#    print(tab)
    a =0
    for j in range(M):
        a += tab[N-j-1]
 #   print(a)
    if a > ans:
        ans = a

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

from collections import deque

H, W = map(int, input().split())
sy, sx = map(lambda x: int(x)-1, input().split())
gy, gx = map(lambda x: int(x)-1, input().split())
maze = [input() for _ in range(H)]

INF = float("INF")
cnt = [[INF]*W for _ in range(H)]

q = deque()
q.append([sy, sx])
cnt[sy][sx] = 0
move = [[1, 0], [-1, 0], [0, 1], [0, -1]]

while q:
    y, x = q.popleft()
    for dy, dx in move:
        ny = y + dy
        nx = x + dx
        if ny < 0 or ny > H-1 or nx < 0 or nx > W-1:
            continue
        if maze[ny][nx] == "." and cnt[ny][nx] > cnt[y][x]:
            cnt[ny][nx] = cnt[y][x]
            q.appendleft([ny, nx])
    for i in range(-2, 2+1):
        for j in range(-2, 2+1):
            wy = y + i
            wx = x + j
            if wy < 0 or wy > H-1 or wx < 0 or wx > W-1:
                continue
            if maze[wy][wx] == "." and cnt[wy][wx] > cnt[y][x] + 1:
                cnt[wy][wx] = cnt[y][x] + 1
                q.append([wy, wx])

ans = cnt[gy][gx] if cnt[gy][gx] != INF else -1
print(ans)

### FIXED CODE ###

from collections import deque

H, W = map(int, input().split())
sy, sx = map(lambda x: int(x)-1, input().split())
gy, gx = map(lambda x: int(x)-1, input().split())
maze = [input() for _ in range(H)]

INF = float("INF")
cnt = [[INF]*W for _ in range(H)]

q = deque()
q.append([sy, sx])
cnt[sy][sx] = 0
move = [[1, 0], [-1, 0], [0, 1], [0, -1]]

while q:
    y, x = q.popleft()
    for dy, dx in move:
        ny = y + dy
        nx = x + dx
        if ny < 0 or ny > H-1 or nx < 0 or nx > W-1:
            continue
        if maze[ny][nx] == "." and cnt[ny][nx] > cnt[y][x]:
            cnt[ny][nx] = cnt[y][x]
            q.appendleft([ny, nx])
        for i in range(-2, 2+1):
            for j in range(-2, 2+1):
                wy = y + i
                wx = x + j
                if wy < 0 or wy > H-1 or wx < 0 or wx > W-1:
                    continue
                if maze[wy][wx] == "." and cnt[wy][wx] > cnt[y][x] + 1:
                    cnt[wy][wx] = cnt[y][x] + 1
                    q.append([wy, wx])

ans = cnt[gy][gx] if cnt[gy][gx] != INF else -1
print(ans)
### BUGGY CODE ###

a,b,n=map(int,input().split())
max=0
x=0
while int(x//b)==0 and x<=n:
    if max < (int((a*x)//b) - a*(int(x//b))):
        max=(int((a*x)//b) - a*(int(x//b)))  
    x+=1
print(max)

### FIXED CODE ###

A,B,N= map(int,input().split())
max_num = 0
x = min(B-1,N)
print(int((A*x)/B)-(A*int(x/B)))
### BUGGY CODE ###

x=int(input())
i = 1
s=set()
while x/i>=1:
  if x%i == 0:
    s.add(i+x//i-2)
  i = i + 1
print(min(s))


### FIXED CODE ###

import math
x=int(input())
s=set()
y=int(math.sqrt(x))
for i in range(y,0,-1):
  if x%i == 0:
    a=i+x//i-2
    s.add(a)
    if min(s)-a <0:
      break
print(min(s))
### BUGGY CODE ###

# -*- coding: utf-8 -*-
#幅優先探索
import sys

N=input()

a=[[] for i in range(N+1)]
#隣接リスト
for i in range(N-1):
	x,y,z=list(map(int,raw_input().split()))
	a[x].append((y,z))
	a[y].append((x,z))

#print a

Q,K=list(map(int,raw_input().split()))


b=[]
for i in range(Q):
	b.append(map(int, raw_input().split()))
#print b



#訪問判別フラグ
F=(N+1)*[0]

#Queue
queue=[]

#距離
dist=[0 for i in range(N+1)]

#先頭から幅優先探索
queue.append(K)
while len(queue) != 0:
	#print queue
	v= queue.pop(0)
	#print "v::"+str(v)
	if F[v]==0:
		F[v]=1

		for u,length in a[v]:
			if F[u]==0:
				queue.append(u)
				dist[u]=dist[v]+length
				#print dist

#print dist


for x in range(len(b)):
	print dist[ b[x][0] ]+ dist[ b[x][1] ]




### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys


N=input()


a=[[] for i in range(N+1)]

#隣接リスト
for i in range(N-1):
	x,y,z=list(map(int,raw_input().split()))
	a[x].append((y,z))
	a[y].append((x,z))

#print a
	

Q,K=list(map(int,raw_input().split()))


b=[]
for i in range(Q):
	b.append(map(int, raw_input().split()))
#print b



#訪問判別フラグ
F=(N+1)*[0]

#Stack
S=[]

#距離
dist=[0 for i in range(N+1)]

#先頭から深さ優先探索
S.append(K)
former_v=0
v=0
while len(S) != 0:
	v=S.pop()
	
	if F[v]==0:
		F[v]=1

		for u,length in a[v]:
			if F[u]==0:
				S.append(u)
				dist[u]=dist[v]+length
				#print dist

#print dist



for x in range(len(b)):

	print dist[ b[x][0] ]+ dist[ b[x][1] ]
### BUGGY CODE ###

import sys
input = sys.stdin.readline

import math
import collections

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def main():
    n = int(input())
    a_li = list(map(int, input().rstrip().split()))
    c = collections.Counter(a_li)
    total = 0
    for k, v in c.items():
        if v > 1:
            total += combinations_count(v, 2)

    for a in a_li:
        n = c[a]
        if n > 1 and n-1 > 1:
            ans = total - combinations_count(n, 2) + combinations_count(n-1, 2)
            print(ans)
        elif n > 1:
            ans = total - combinations_count(n, 2)
            print(ans)
        else:
            ans = total
            print(ans)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
input = sys.stdin.readline

import collections

from operator import mul
from functools import reduce

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

def main():
    n = int(input())
    a_li = list(map(int, input().rstrip().split()))
    c = collections.Counter(a_li)
    total = 0
    dict_1 = {}
    dict_2 = {}
    for k, v in c.items():
        if v > 1:
            num = combinations_count(v, 2)
            total += num
            dict_1[k] = num
            if v - 1 > 1:
                dict_2[k] = combinations_count(v-1, 2)
            else:
                dict_2[k] = 0
        else:
            dict_1[k] = 0
            dict_2[k] = 0

    for a in a_li:
        ans = total - dict_1[a] + dict_2[a]
        print(ans)

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

from fractions import gcd
from functools import reduce

def gcd1(*numbers):
  return reduce(gcd, numbers)

k = int(input())
ans = 0
g = []
for a in range(1,k+1):

  for b in range(1,k+1):
    
    g.append(gcd(a,b))


for c in range(1, k+1):
  for i in g:
    ans += gcd(c,i)

print(ans)

### FIXED CODE ###

from math import gcd

k=int(input())
ans=0
for i in range(1,k+1):
  for j in range(1,k+1):
    for g in range(1,k+1):
      ans += gcd(gcd(i,j), g)

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

S=input()
A=len(S)
for i in range(int(A/2)):
    S=S.replace("01","").replace("10","")
print(A-len(S))

### FIXED CODE ###

S=input()
a_sum=0
b_sum=0
for i in range(len(S)):
    if S[i]=="1":
        b_sum+=1
    else:
        a_sum+=1
print(2*min(a_sum,b_sum))
### BUGGY CODE ###

a,b,c,k = map(int,input().split())
for i in range(k):
    a,b,c = b+c,a+c,a+b
ans = a-b
if ans > 10**18:
    print('Unfair')
else:
  print(ans)

### FIXED CODE ###

a,b,c,k = map(int,input().split())
if k%2 == 0:
    print(a-b)
else:
    print(b-a)
### BUGGY CODE ###

ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n, m = nm()

a = sorted(nl())

pos = 0

changer = []

for i in range(m):
    b, c = nm()
    changer.append((c, b))

changer = sorted(changer)[::-1]


for i in range(m):

    c = changer[i]
    for j in range(c[1]):
        while pos < n:
            if a[pos] < c[0]:
                a[pos] = c[0]
                break
            pos += 1

print(sum(a))


### FIXED CODE ###

ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n, m = nm()

a = sorted(nl())

pos = 0

changer = []

for i in range(m):
    b, c = nm()
    changer.append((c, b))

changer = sorted(changer)[::-1]


for i in range(m):

    c = changer[i]
    for j in range(c[1]):
        while pos < n:
            if a[pos] < c[0]:
                a[pos] = c[0]
                break
            pos += 1
    if pos >= n:
        break

print(sum(a))
### BUGGY CODE ###

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

s = input()

count = []

for i in range(0, q) :
    l, r = map(int, input().split())
    count.append(s[l-1:r].count('AC'))

for j in range(0,q) :
    print(count[j])


### FIXED CODE ###

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

s = input()

count = [0] * n

for i in range(n) :
    if s[i-1] + s[i] == 'AC' :
        count[i] = count[i-1] + 1
    else :
        count[i] = count[i-1]

for j in range(0, q) :
    l, r = map(int, input().split())
    print(count[r-1] - count[l-1])
### BUGGY CODE ###

n=int(input())
list=[input() for i in range(n)]
lists=[]
for i in list:
  lists.append(''.join(sorted(i)))
  
#ここまででソートしたリストを得た。ここまではオーケー
cnt=0
for i in range(n):
  for k in range(i+1,n):
    if lists[i]==lists[k]:
        cnt+=1
  
  
print(cnt)



### FIXED CODE ###

n = int(input())

words = {}
anagrams = 0

for i in range(n):
    word = "".join(sorted(input()))
    if word not in words:
        words[word] = 1
    else:
        anagrams += words[word]
        words[word] += 1

print(anagrams)
### BUGGY CODE ###

from collections import Counter

n, m = map(int, input().split())
ab = sorted([list(map(int, input().split())) for i in range(n)])
c = [[]] * m
a, b = ab[0]
last = a
ad = [b]
for i in range(1, n):
    a, b = ab[i]
    if a == last:
        ad.append(b)
    else:
        if last <= m:
            c[last - 1] = ad
        ad = [b]
    last = a
if a <= m:
    c[a - 1] = ad
choice = Counter()
ans = 0
for i in range(m):
    choice = choice + Counter(c[i])
    if choice:
        use = max(choice)
        ans += use
        choice[use] -= 1
print(ans)


### FIXED CODE ###

import heapq

n, m = map(int, input().split())
ab = sorted([list(map(int, input().split())) for i in range(n)])
c = [[]] * m
a, b = ab[0]
last = a
ad = [b]
for i in range(1, n):
    a, b = ab[i]
    if a == last:
        ad.append(b)
    else:
        if last <= m:
            c[last - 1] = ad
        ad = [b]
    last = a
if a <= m:
    c[a - 1] = ad
a = [3, 0, 2, 6]
choice = []
heapq.heapify(choice)
ans = 0
for i in range(m):
    for j in c[i]:
        heapq.heappush(choice, -j)
    if choice:
        ans -= heapq.heappop(choice)
print(ans)
### BUGGY CODE ###

stdin =open(0).read().split('\n')
N=int(stdin[0])
A=list(map(int,stdin[1].split()))
d=dict(zip(set(A), [0]*len(set(A))))
ans=0
for i in set(A):
    d[i]=A.count(i)
    ans+=d[i]*(d[i]-1)//2
for j in range(N):
    num = d[A[j]]
    print(ans-num*(num-1)//2+(num-1)*(num-2)//2)

### FIXED CODE ###

stdin =open(0).read().split('\n')
N=int(stdin[0])
A=list(map(int,stdin[1].split()))
from collections import Counter
C=Counter(A)
ans=0
for i in C.values():
    ans+=i*(i-1)//2
for a in A:
    num = C[a]
    print(ans-num*(num-1)//2+(num-1)*(num-2)//2)
### BUGGY CODE ###

R,G,B,N = map(int,input().split())
ans = 0
for i in range(0,N+1,R):
  for j in range(0,N+1,G):
    if i+j<=N and (N-i-j)%B == 0:
        ans+=1
print(ans)


### FIXED CODE ###

R,G,B,N = map(int,input().split())
ans = 0
for i in range(0,N+1,R):
  for j in range(0,N+1,G):
    if i+j<=N:
      if (N-i-j)%B == 0:
        ans+=1
print(ans)
### BUGGY CODE ###

import math
a=[0,0,0]
N = int(input())

wa=0
for i in range(1, N+1):
    a[0]=i
    for j in range(1,N+1):
        a[1]=j
        for k in range(1,N+1):
            a[2]=k
            
            ans = a[0]

            for l in range(1, 3):
                ans = math.gcd(ans, a[l])

            wa=wa+ans

print(wa)


### FIXED CODE ###

import math
from functools import reduce

def gcd(a):
    return reduce(math.gcd, a)

a=[0,0,0]
N = int(input())

wa=0
for i in range(1, N+1):
    a[0]=i
    for j in range(1,N+1):
        a[1]=j
        for k in range(1,N+1):
            a[2]=k
            
            wa=wa+gcd(a)

print(wa)
### BUGGY CODE ###

from collections import Counter
from scipy.misc import comb
N = int(input())
A = input().split()
C = Counter(A)
def banned_count(seq):
    for i in range(N):
        C[A[i]] -= 1
        d = [comb(j, 2, exact=True) for j in C.values()]
        count = sum(d)
        print(count)
        C[A[i]] += 1
banned_count(A)

### FIXED CODE ###

from collections import Counter
from scipy.misc import comb
N = int(input())
A = input().split()
C = Counter(A)
s = sum([comb(j, 2, exact=True) for j in C.values()])
for i in range(N):
    print(s-C[A[i]]+1)
### BUGGY CODE ###

A = list()
B = list()
i=0
X = int(input())
while(True):
    tmp = i**5
    A.append(tmp)
    B.append(i)
    if i%2 ==1:
        A.append(tmp*-1)
        B.append(i)
    if tmp >= 10**20:
        break
    i +=1
result = [0,0]
for i in range(len(A)):
    for j in range(len(A)):
        if A[i] -A[j] ==X:
            result[0] = B[i]
            result[1] = B[j]
            break

print(*result)

### FIXED CODE ###

X = int(input())
A = [i**5 for i in range(-118,120)]
A_posi = [i for i in range(-118,120)]
B = [i**5 for i in range(-119,119)]
B_posi = [i for i in range(-119,119)]
result = [0]*2
for i in range(len(A)):
    for j in range(len(B)):
        if A[i] -B[j] ==X:
            result[0] = A_posi[i]
            result[1] = B_posi[j]
            break
print(*result)
### BUGGY CODE ###

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


x = int(input().strip())
abs_x = abs(x)

def X(a, b):
    return a**5 - b**5

def X_plus(a, b):
    return a**5 + b**5

a = 2
b = 1

while True:
    #print(a, b)
    if X(a, b) == abs_x:
        if x < 0:
            a = -a
            b = -b
        print(a,b)
        exit()

    if (a-b) > 1:
        b += 1
    elif a-b == 1:
        if X(a, b) < abs_x:
            a += 1
        else:
            #print("引き算では無理")
            break
    else:
        print("Error")
        exit()

#print("足し算を判定")

a = 0
b = 0

while True:
    if X_plus(a, b) == abs_x:
        b = -b
        if x < 0:
            a = -a
            b = -b
        print(a, b)
        exit()

    if X_plus(a+1, b) <= abs_x:
        a += 1
        b = 0
    else:
        if X_plus(a, b+1) <= abs_x:
            b += 1
        else:
            a -= 1
            b = 0

### FIXED CODE ###

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


x = int(input().strip())
abs_x = abs(x)

def X(a, b):
    return a**5 - b**5

def X_plus(a, b):
    return a**5 + b**5

a = -118
b = -119


for a in range(-118, 119):
    #print(a)
    for b in range(-119, 118):
        #print(b)
        if X(a,b) == x:
            print(a,b)
            exit()

#print("not found")
### BUGGY CODE ###

N=int(input())
A = list(map(int,input().split()))
l = len(A)
ans=0
for idx, val in enumerate(A):
    if idx == l - 1:
        print(ans%(10**9+7))
        exit()
    for x in range(idx+1, l):
        num = A[idx] ^ A[x]
        ans += num

### FIXED CODE ###

import numpy as np
 
MOD = 10 ** 9 + 7
 
N = int(input())
A = np.array(list(map(int, input().split())),np.int64)
 
answer = 0
for n in range(63):
    B = (A >> n) & 1
    x = np.count_nonzero(B)
    y = N - x
    x *= y
    for _ in range(n):
        x *= 2
        x %= MOD
    answer += x
answer %= MOD
print(answer)