mod=10**9+7
def pairORSum(arr, n) : 
    ans = 0     # Initialize result 
  
    # Consider all pairs (arr[i], arr[j)  
    # such that i < j 
    for i in range(0, n) : 
          
        for j in range(i + 1, n) : 
              
            ans = ans + (arr[i] ^ arr[j]) 
              
    return ans 
      
  
# Driver Code 
n=int(input())
arr=list(map(int,input().split()))
print(pairORSum(arr, n)%mod) 