from collections import Counter
import sys
import numpy as np
input = sys.stdin.readline


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


if __name__ == '__main__':
    main()
