from itertools import combinations


def main(n: int, a: list):
    ans = 0

    for f, l in combinations(a, 2):
        ans += f ^ l

    if ans > 10**9 + 7:
        print(ans % (10**9 + 7))
    else:
        print(ans)


if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    main(n, a)
