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