import sys
from math import ceil, log2

input = sys.stdin.readline

def main():
    MOD = 10**9 + 7
    
    N = int(input())
    A = list(map(int, input().split()))
    K = ceil(log2(max(max(A), 1)))
    nums = [[0,0] for i in range(K)]
    ks = [(i, 2**i) for i in range(K)]
    
    for i, a in enumerate(A):
        for j, k in ks:
            n = a & k > 0
            nums[j][n] += 1
    ans = 0
    
    for a in A:
        for j, k in ks:
            n = a & k > 0
            nums[j][n] -= 1
            ans += k * nums[j][not n] % MOD
            
    print(ans%MOD)

if __name__ == '__main__':
    main()

