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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)

typedef long long ll;
typedef pair<int,int> p;



class DXorSum4 {
public:
    int dy[4]={-1,1,0,0};
    int dx[4]={0,0,1,-1};

	void solve(std::istream& in, std::ostream& out) {
	    int N;
	    in >> N;
	    vector<ll> A(N);
	    vector<ll> digit_zero(60, 0);
	    vector<ll> digit_one(60, 0);
	    REP(i, N) {
	        in >> A[i];
	    }
	    REP(i,N) {
            REP(j, 60) {
                if (A[i] >> j & 1) {
                    digit_one[j]++;
                } else {
                    digit_zero[j]++;
                }
            }
	    }
	    ll ans = 0;
	    REP(i, N) {
	        REP(j,  60) {
                if (A[i] >> j & 1) {
                    ans += ((1L << j) % ll(1e9+7)) * digit_zero[j];
                    digit_one[j]--;
                    ans %= ll(1e9+7);
                } else {
                    ans +=  ((1L << j) % ll(1e9+7)) * digit_one[j];
                    digit_zero[j]--;
                    ans %= ll(1e9+7);
                }
	        }
	    }
	    out << ans << endl;
	}
};
