import sys

input=sys.stdin.readline

#from collections import defaultdict

#d = defaultdict(int)

#import fractions

#import math

#import collections

#from collections import deque

#from bisect import bisect_left

#from bisect import insort_left

#N = int(input())

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

#S = list(input())

#S.remove("\n")

#N,M = map(int,input().split())

#S,T = map(str,input().split())

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

#S = [input() for _ in range(N)]

#A = [list(map(int,input().split())) for _ in range(N)]

#import itertools

#import heapq

from collections import defaultdict

MOD = pow(10,9)+7

N = int(eval(input()))

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

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

for k in A:

    c = 0

    while k > 0:

        if k % 2 == 1:

            d[c][0] -= 1

            d[c][1] += 1

        k = k // 2

        c += 1

s = 0

for i in range(60):

    li = d[i]

    s += (li[0]*li[1]*pow(2,i,MOD))%MOD

print((s%MOD))
import sys

input=sys.stdin.readline

#from collections import defaultdict

#d = defaultdict(int)

#import fractions

#import math

#import collections

#from collections import deque

#from bisect import bisect_left

#from bisect import insort_left

#N = int(input())

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

#S = list(input())

#S.remove("\n")

#N,M = map(int,input().split())

#S,T = map(str,input().split())

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

#S = [input() for _ in range(N)]

#A = [list(map(int,input().split())) for _ in range(N)]

#import itertools

#import heapq

#import numpy as np

import numpy as np

from collections import defaultdict

MOD = pow(10,9)+7

N = int(eval(input()))

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

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

A = np.array(A)

ans = 0

for m in range(60):

    B = (A >> m) & 1

    x = np.count_nonzero(B)

    x *= (N-x)

    x *= pow(2,m,MOD)

    ans += x

print((ans%MOD))
import sys

input = sys.stdin.readline
# from collections import defaultdict
# d = defaultdict(int)
# import fractions
# import math
# import collections
# from collections import deque
# from bisect import bisect_left
# from bisect import insort_left
# N = int(input())
# A = list(map(int,input().split()))
# S = list(input())
# S.remove("\n")
# N,M = map(int,input().split())
# S,T = map(str,input().split())
# A = [int(input()) for _ in range(N)]
# S = [input() for _ in range(N)]
# A = [list(map(int,input().split())) for _ in range(N)]
# import itertools
# import heapq
from collections import defaultdict

MOD = pow(10, 9) + 7
N = int(eval(input()))
d = [[N, 0] for _ in range(60)]
A = list(map(int, input().split()))
for k in A:
    c = 0
    while k > 0:
        if k % 2 == 1:
            d[c][0] -= 1
            d[c][1] += 1
        k = k // 2
        c += 1
s = 0
for i in range(60):
    li = d[i]
    s += (li[0] * li[1] * pow(2, i, MOD)) % MOD
print((s % MOD))

import sys

input = sys.stdin.readline
# from collections import defaultdict
# d = defaultdict(int)
# import fractions
# import math
# import collections
# from collections import deque
# from bisect import bisect_left
# from bisect import insort_left
# N = int(input())
# A = list(map(int,input().split()))
# S = list(input())
# S.remove("\n")
# N,M = map(int,input().split())
# S,T = map(str,input().split())
# A = [int(input()) for _ in range(N)]
# S = [input() for _ in range(N)]
# A = [list(map(int,input().split())) for _ in range(N)]
# import itertools
# import heapq
# import numpy as np
import numpy as np
from collections import defaultdict

MOD = pow(10, 9) + 7
N = int(eval(input()))
d = [[N, 0] for _ in range(60)]
A = list(map(int, input().split()))
A = np.array(A)
ans = 0
for m in range(60):
    B = (A >> m) & 1
    x = np.count_nonzero(B)
    x *= N - x
    x *= pow(2, m, MOD)
    ans += x
print((ans % MOD))

+# import numpy as np +import numpy as np -for k in A: -    c = 0 -    while k > 0: -        if k % 2 == 1: -            d[c][0] -= 1 -            d[c][1] += 1 -        k = k // 2 -        c += 1 -s = 0 -for i in range(60): -    li = d[i] -    s += (li[0] * li[1] * pow(2, i, MOD)) % MOD -print((s % MOD)) +A = np.array(A) +ans = 0 +for m in range(60): +    B = (A >> m) & 1 +    x = np.count_nonzero(B) +    x *= N - x +    x *= pow(2, m, MOD) +    ans += x +print((ans % MOD))