#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
const long long SZ = 3e5 + 4;
const double EPS = 1e-7;
const long long mod = 1e9 + 7;
const long long inf = 1e9 + 9;
struct custom_hash {
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return x + FIXED_RANDOM;
  }
};
long long n;
long long a[SZ];
void read() {
  cin >> n;
  for (long long i = 0; i < n; ++i) {
    cin >> a[i];
  }
}
void solve() {
  vector<vector<long long>> suf(n, vector<long long>(60));
  for (long long i = 0; i < n; ++i) {
    long long j = 0;
    long long tmp = a[i];
    while (tmp > 0) {
      if (tmp % 2) {
        ++suf[i][j];
      }
      tmp /= 2;
      ++j;
    }
  }
  for (long long i = n - 2; i >= 0; --i) {
    for (long long j = 0; j < 60; ++j) {
      suf[i][j] += suf[i + 1][j];
    }
  }
  long long ans = 0;
  for (long long i = 0; i < n - 1; ++i) {
    bitset<60> b(a[i]);
    for (long long j = 0; j < 60; ++j) {
      if (b[j]) {
        ans += (1ll << j) * (n - i - 1 - suf[i + 1][j]);
        ans %= mod;
      } else {
        ans += (1ll << j) * suf[i + 1][j];
        ans %= mod;
      }
    }
  }
  cout << ans;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  read();
  solve();
  return 0;
}
