import sys

input = sys.stdin.readline

sys.setrecursionlimit(10**7)

from collections import Counter, deque

#from collections import defaultdict

from itertools import combinations, permutations, accumulate, groupby

#from itertools import product

from bisect import bisect_left,bisect_right

from heapq import heapify, heappop, heappush

from math import floor, ceil

#from operator import itemgetter



#inf = 10**17

mod = 10**9 + 7



n = int(eval(input()))

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

res = 0

for i in range(60):

    cnt = 0

    for j in a:

        if (j>>i) & 1:

            cnt += 1

    res += ((cnt*(n-cnt))*2**i) % mod

print((res%mod))

def main():

    import sys

    input = sys.stdin.readline

    sys.setrecursionlimit(10**7)

    from collections import Counter, deque

    #from collections import defaultdict

    from itertools import combinations, permutations, accumulate, groupby

    #from itertools import product

    from bisect import bisect_left,bisect_right

    from heapq import heapify, heappop, heappush

    from math import floor, ceil

    #from operator import itemgetter



    #inf = 10**17

    mod = 10**9 + 7



    n = int(eval(input()))

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

    res = 0

    for i in range(60):

        cnt = 0

        for j in a:

            if (j>>i) & 1:

                cnt += 1

        res += ((cnt*(n-cnt))*2**i) % mod

    print((res%mod))



if __name__ == '__main__':

    main()
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque

# from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby

# from itertools import product
from bisect import bisect_left, bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil

# from operator import itemgetter
# inf = 10**17
mod = 10**9 + 7
n = int(eval(input()))
a = list(map(int, input().split()))
res = 0
for i in range(60):
    cnt = 0
    for j in a:
        if (j >> i) & 1:
            cnt += 1
    res += ((cnt * (n - cnt)) * 2**i) % mod
print((res % mod))

def main():
    import sys

    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque

    # from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby

    # from itertools import product
    from bisect import bisect_left, bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil

    # from operator import itemgetter
    # inf = 10**17
    mod = 10**9 + 7
    n = int(eval(input()))
    a = list(map(int, input().split()))
    res = 0
    for i in range(60):
        cnt = 0
        for j in a:
            if (j >> i) & 1:
                cnt += 1
        res += ((cnt * (n - cnt)) * 2**i) % mod
    print((res % mod))


if __name__ == "__main__":
    main()

-import sys +def main(): +    import sys -input = sys.stdin.readline -sys.setrecursionlimit(10**7) -from collections import Counter, deque +    input = sys.stdin.readline +    sys.setrecursionlimit(10**7) +    from collections import Counter, deque -# from collections import defaultdict -from itertools import combinations, permutations, accumulate, groupby +    # from collections import defaultdict +    from itertools import combinations, permutations, accumulate, groupby -# from itertools import product -from bisect import bisect_left, bisect_right -from heapq import heapify, heappop, heappush -from math import floor, ceil +    # from itertools import product +    from bisect import bisect_left, bisect_right +    from heapq import heapify, heappop, heappush +    from math import floor, ceil -# from operator import itemgetter -# inf = 10**17 -mod = 10**9 + 7 -n = int(eval(input())) -a = list(map(int, input().split())) -res = 0 -for i in range(60): -    cnt = 0 -    for j in a: -        if (j >> i) & 1: -            cnt += 1 -    res += ((cnt * (n - cnt)) * 2**i) % mod -print((res % mod)) +    # from operator import itemgetter +    # inf = 10**17 +    mod = 10**9 + 7 +    n = int(eval(input())) +    a = list(map(int, input().split())) +    res = 0 +    for i in range(60): +        cnt = 0 +        for j in a: +            if (j >> i) & 1: +                cnt += 1 +        res += ((cnt * (n - cnt)) * 2**i) % mod +    print((res % mod)) + + +if __name__ == "__main__": +    main()