#include<iostream>
using namespace std;
#include<vector>
#define int long long int
#define mod 1000000007
int power(int a,int b)
{
	if(b==0)
	  return 1;
    int r=power(a,b/2);
    if(b%2==0)
       return r*r;
    else
       return a*r*r;
}
int32_t main()
{
     int n,j,i;
     cin>>n;
     int arr[n];
     for(j=0;j<n;j++)
       cin>>arr[j];
     int bits[n][60]={0};
     for(j=0;j<n;j++)
     {
		 int x=arr[j];
		 for(i=59;i>=0;i--)
		 {
			 if(x>=power(2,i))
			 {
				 bits[j][i]=1;
				 x-=power(2,i);
			 }
			 else
			 {
				 bits[j][i]=0;
			 }
		 }
	 }
	 int suffix[n+1][60]={0};
	 for(j=0;j<=n;j++)
	 {
		 for(i=0;i<60;i++)
		   suffix[j][i]=0;
	 }
	 for(j=n-1;j>=0;j--)
	 {
		 
		 for(i=59;i>=0;i--)
		 {
			 suffix[j][i]=bits[j][i]+suffix[j+1][i];
		 }
	 }
	 int answer=0;
	 for(j=0;j<n-1;j++)
	 {
		 int total=n-j-1;
		 for(i=59;i>=0;i--)
		 {
			 if(bits[j][i]==1)
			 {
				 int zeros=total-suffix[j+1][i];
				 answer=answer+((zeros%mod)*(power(2,i)%mod))%mod;
				 answer=answer%mod;
			 }
			 else
			 {
				 int ones=suffix[j+1][i];
				 answer=answer+((ones%mod)*(power(2,i)%mod))%mod;
				 answer=answer%mod;
			 }
		 }
	 }
	 cout<<answer<<endl;
}
