#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const int MOD = 1000000000 + 7;
template <typename tuple<long long, long long, long long>>
inline string toString(const tuple<long long, long long, long long> &a) {
  ostringstream oss;
  oss << a;
  return oss.str();
};
int main() {
  int N;
  cin >> N;
  vector<long long> a(N);
  for (int i = 0; i < (N); i++) cin >> a[i];
  vector<vector<long long>> dig(65, vector<long long>(N + 1, 0));
  for (int i = 0; i < (60); i++) {
    for (int j = 0; j < (N); j++) {
      int one = ((a[j] >> i) & 1) ? 1 : 0;
      dig[i][j + 1] = dig[i][j] + one;
    }
  }
  long long ans = 0;
  for (int i = 0; i < (60); i++) {
    long long cnt = 0;
    for (int j = 0; j < (N - 1); j++) {
      long long num = (dig[i][N] - dig[i][j + 1] + MOD) % MOD;
      if ((a[j] >> i) & 1) {
        cnt = (cnt + (N - (j + 1) - num + MOD) % MOD) % MOD;
      } else {
        cnt = (cnt + num) % MOD;
      }
    }
    ans = (ans + ((1LL << i) * cnt) % MOD) % MOD;
  }
  cout << ans % MOD << endl;
}
