MOD = 10 ** 9 + 7
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    t = 0
    for i, Ai in enumerate(A[:-1]):
        t = (t + sum(Ai ^ Aj for Aj in A[i + 1:])) % MOD
    print(t)

main()
