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

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