import sys
input = sys.stdin.readline

def func(x, nn):
    value = 0
    for i in range(nn - 1):
        for j in range(i + 1, nn):
            value += x[i] ^ x[j]
    ans = value % (10 ** 9 + 7)
    return ans

def main():
    n = int(input())
    li = list(map(int, input().split()))
    print(func(li, n))

if __name__ == '__main__':
    main()