#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a>b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD =1000000007;//1e9 + 7;



int main(){
	int n;
    cin>>n;
    ll s[1010101];
    ll aa[1010]={};
    ll bb[1010]={};
    ll ma=0;
    rep(i,n){
        cin>>s[i];
        int j=0;;
        while(111>=j)){
            if(s[i]&(1<<j)){
                ma+=bb[j]*(1<<j);
                ma%=MOD;
                aa[j]++;
            }
            else {
                ma+=aa[j]*(1<<j);
                ma%=MOD;
                bb[j]++;
            }
            j++; 
        }
        
        
        
    }
    cout<<ma<<endl;

}