from collections import defaultdict
import sys
input = sys.stdin.readline
import numpy as np
MOD = 10 ** 9 + 7


def main():
    N = int(input())
    A = np.array(list(map(int, input().split())))
    ans = 0
    for a in A:
        ans += np.sum(A ^ a)
        ans %= MOD
    print(ans // 2)


if __name__ == '__main__':
    main()
