def abc147_d():
    n = int(input())
    a = list(map(int, input().split()))

    result = 0

    for i in range(len(a) - 1):
        for j in range(i, len(a)):
            result += a[i] ^ a[j]    
    result = result % (10**9 +7)
    print(result)

if __name__ == '__main__':
    abc147_d()