import sys
import collections


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    a = list(map(int, readline().split()))
    d = collections.defaultdict(int)
    for i in range(n):
        d[a[i]] += 1
    t = 0
    for v in a:
        d[v] -= 1
        if d[v] == 0:
            d.pop(v)
        for k2, v2 in d.items():
            t += (v ^ k2) * v2
            t %= mod
    print(t)


if __name__ == '__main__':
    solve()
