#include <bits/stdc++.h>
using namespace std;
long long f[66];
int32_t main() {
  ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
  long long n;
  cin >> n;
  vector<long long> v(n);
  for (long long i = 0; i < (n); ++i) {
    cin >> v[i];
    for (long long j = 0; j <= 60; j++) {
      if (v[i] & 1ll << j) f[j]++;
    }
  }
  long long an = 0;
  for (long long i = n - 1; i > 0; i--) {
    for (long long j = 0; j <= 60; j++) {
      if (v[i] & 1ll << j) f[j]--;
    }
    for (long long j = 0; j <= 60; j++) {
      if (v[i] & 1ll << j) {
        an += ((i - f[j]) % 1000000007 * (1ll << j) % 1000000007) % 1000000007;
      } else
        an += ((f[j]) % 1000000007 * (1ll << j) % 1000000007) % 1000000007;
      an %= 1000000007;
    }
    an %= 1000000007;
  }
  cout << an;
  return 0;
}
