#include <bits/stdc++.h>
using namespace std;
const long long inf = (long long)(1e17 + 17);
const long long mod = (long long)(1e9 + 7);
long long modadd(long long x, long long y) { return (x % mod + y % mod) % mod; }
long long modmul(long long x, long long y) { return (x % mod * y % mod) % mod; }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  vector<long long> a(n);
  vector<vector<long long> > sb(n + 1, vector<long long>(61, 0));
  for (auto &it : a) cin >> it;
  for (long long i = n - 1; i >= 0; i--) {
    for (long long j = 0; j <= 60; j++) {
      sb[i][j] += sb[i + 1][j];
      if (a[i] & (1ll << j)) sb[i][j]++;
    }
  }
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j <= 60; j++) {
      if (a[i] & (1ll << j)) {
        long long tot = (n - (i + 1));
        ans = modadd(ans, modmul((tot - (sb[i + 1][j])), (1ll << j)));
      } else {
        ans = modadd(ans, modmul(sb[i + 1][j], (1ll << j)));
      }
    }
  }
  cout << ans << "\n";
  return 0;
}
