#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
template<class T>vector<T> _vec(size_t a,T v){return vector<T>(a,v);}
template<class T, class... Ts>auto _vec(size_t a, Ts... ts){return vector<decltype(_vec<T>(ts...))>(a, _vec<T>(ts...));}

template<ll MOD=ll(1e9+7)>
ll mod_pow(ll n,ll p){
  ll ans=1LL;
  while(p){
    if(p&1)ans*=n;
    n*=n;
    p>>=1;
    ans%=MOD;
    n%=MOD;
  }
  return ans;
}


signed main(){

  ll n;
  cin>>n;
  vector<ll> a(n);
  cin>>a;

  vector<bitset<64>> bit(n);
  rep(i,n){
    bit[i]=bitset<64>(a[i]);
  }
  vector<vector<ll>>cnt(n,vector<ll>(64));
  for(int i=n-1;i>=0;--i){
    if(i+1<n)cnt[i]=cnt[i+1];
    rep(j,64)if(bit[i][j])cnt[i][j]++;
  }

  ll ans = 0;
  rep(i,n-1){
    ll num=n-i-1;
    ll tmp=0;
    rep(j,64){
      if(bit[i][j]){
        tmp += (num-cnt[i+1][j])*(1LL<<j);
        tmp%=MOD;
      }
      else if(cnt[i+1][j]){
        tmp += cnt[i+1][j]*(1LL<<j);
        tmp %= MOD;
      }
    }
    ans += tmp;
    ans %= MOD;
  }
  cout<<(ans)<<endl;


}