def main():
    n = int(input())
    a = list(map(int, input().split()))
    mod = 10**9+7
    max_len = len(format(max(a), "b"))
    b = [0 for _ in range(max_len)]

    for i in range(n):
        count = 0
        while a[i] > 0:
            b[count] += a[i]%2
            a[i] //= 2
            count += 1

    result = 0
    for i in range(max_len):
        r = b[i]*(n-b[i])%mod
        for j in range(i):
            r = r*2 %mod
        result += r
    print(result%mod)

if __name__=="__main__":
    main()