def solve():
    from itertools import combinations
    
    mod = 10 ** 9 + 7
    N = int(input())
    A = tuple(map(int, input().split()))
    
    ans = sum(ai ^ aj for ai, aj in combinations(A, 2)) % mod
    
    print(ans)

solve()