import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N = int(input())
    A = tuple(map(int, input().split()))
    MOD = 10 ** 9 + 7

    ans = 0
    for i, a in enumerate(A[:-1]):
        ans += sum([a ^ b for b in A[i+1:]]) % MOD
        ans %= MOD
    print(ans)

if __name__ == '__main__':
    main()