import itertools


def xor_pair_sum(ar, n): 
    total = 0
    nums = list(itertools.combinations(ar,2))
    return sum([i[0] ^ i[1] for i in nums])
  
  
# Driver program to test the above function 
n = int(input()) 
nums = list(map(int, input().split()))
mod = 1000000007
print(xor_pair_sum(nums, n) % mod)