N = int(input())
nums = list(map(int, input().split()))
sum = 0
for i in nums:
    for j in nums:
        if i < j:
            sum += i^j          
print(int(sum % (1e+9 + 7)))      
            
      