// An efficient C++ program to compute 
// sum of bitwise OR of all pairs 
#include <bits/stdc++> 
using namespace std; 

// Returns sum of bitwise OR 
// of all pairs 
long long int sumXOR(int arr[], int n) 
{ 
	long long int sum = 0; 
	for (int i = 0; i < 60; i++) 
	{ 
		// Count of zeros and ones 
		int zc = 0, oc = 0; 
		
		// Individual sum at each bit position 
		long long int idsum = 0; 
		for (int 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; 
	} 
	return sum%(1000000007); 
} 

int main() 
{ 
	long long int sum = 0,n; 
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)
	  cin>>arr[i];
	sum = sumXOR(arr, n); 
	cout << sum; 
	return 0; 
} 
