#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
// Returns sum of bitwise OR 
// of all pairs 
ll sumXOR(ll arr[], ll n) 
{ 
    ll sum = 0; 
    for (ll i = 0; i < 32; i++)  
    { 
        //  Count of zeros and ones 
        ll zc = 0, oc = 0;  
          
        // Individual sum at each bit position 
        ll idsum = 0;  
        for (ll j = 0; j < n; j++) 
        { 
            if (arr[j] % 2 == 0) 
                zc++; 
            else
                oc++; 
            arr[j] /= 2; 
        } 
          
        // calculating individual bit sum  
        idsum = oc * zc * (1 << i);  
  
        // final sum     
        sum += idsum;
        sum%=1000000007;
    } 
    return sum; 
} 
  
int main() 
{ 
    ll sum = 0; 
    ll a;
    cin>>a;
    int arr[a];
    for(ll i=0;i<a;i++){
      cin>>arr[i];
    }
    int n = sizeof(arr) / sizeof(arr[0]); 
    sum = sumXOR(arr, n); 
    cout<<sum<<endl; 

} 