#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const long long mod = 1e9 + 7;
const long long big = 1e18;
const double PI = 2 * asin(1);
long long DP[61][300005];
int main() {
  int N;
  cin >> N;
  long long A[N];
  long long two;
  for (int i = 0; i < N; ++i) cin >> A[i];
  for (int i = 0; i < N; ++i) {
    two = 1;
    for (int bit = 0; bit < 61; ++bit) {
      if ((A[i] & two) != 0) DP[bit][i]++;
      two *= 2;
    }
  }
  for (int bit = 0; bit < 61; ++bit) {
    for (int i = 1; i < N; ++i) {
      DP[bit][i] += DP[bit][i - 1];
    }
  }
  long long ans = 0;
  for (int i = 0; i < N; ++i) {
    two = 1;
    for (int bit = 0; bit < 61; ++bit) {
      if ((A[i] & two) != 0) {
        ans += two * (N - 1 - i - (DP[bit][N - 1] - DP[bit][i])) % mod;
        ans %= mod;
      } else {
        ans += two * (DP[bit][N - 1] - DP[bit][i]) % mod;
        ans %= mod;
      }
      two *= 2;
    }
  }
  cout << ans << endl;
}
