import sys
def main():
    MOD = 10**9+7
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int, input().split()))

    count = [0] * 61

    for a in A:
        for i, c in enumerate(format(a, '061b')):
            if c == '1':
                count[i] += 1
    ans = 0
    for j, a in enumerate(A):
        for i, c in enumerate(format(a, '061b')):
            if c == '1':
                count[i] -= 1
                ans = (ans + pow(2, 60-i, MOD) * (N-1-j-count[i]))%MOD
            else:
                ans = (ans + pow(2, 60-i, MOD) * count[i])%MOD
    print(ans)


if __name__ == '__main__':
    main()
