#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define M 1000000007

long long int Xorsum(int arr[], int n)
{
    long long int sum = 0;
    for (int i = 0; i < 32; 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 =((sum%M) +(dsum%M))%M;
    }
    return sum;
}
int main()
{
int t,n,ans=0,a[300000],sum=0,i,j;
cin>>n;
for(i=0;i<n;i++)
{
    cin>>a[i];
    sum=sum+a[i];
}
/*for(i=0;i<n-1;i++)
{
    ans=((ans%M)+((sum-p[i])%M))%M;
}
*/
ans=Xorsum(a,n);
ans=ans;
cout<<ans%M<<endl;
return 0;
}
