#include<bits/stdc++.h>
using namespace std;
typedef int64_t LL;
#define rep(i,N) for(LL i=0;i<(int)N;i++)
const int MOD=1e9+7;
const LL SCORE=1LL<<20,Z=pow(SCORE,2)+SCORE+1;
int main()
{
  int N;
  LL A=0,x,y;
  vector<LL> bit(20,0);
  cin>>N;
  while(cin>>x)rep(i,20)bit.at(i)+=x>>i&Z,x>>1;
  rep(i,20){x=bit.at(i);rep(j,3){y=x&SCORE-1;x/=SCORE;A=fmod(A+fmod(y%MOD*(N-y)%MOD*pow(2,i+20*j),MOD),MOD);}}
  return cout<<A<<endl,0;
}