from collections import Counter
import sys
input = sys.stdin.readline


def main():
    mod = 10 ** 9 + 7
    n = int(input())
    a = list(map(int, input().split()))
    ans = 0
    a_dict = Counter(a)
    for i in range(n):
        a_dict[a[i]] -= 1
        for j in a_dict:
            ans += a_dict[j] * (a[i] ^ j)
    print(ans % mod)


if __name__ == '__main__':
    main()
