#include <bits/stdc++.h>
using namespace std;
const int NAX = 3e5 + 5, MOD = 1e9 + 7;
long long a[NAX], ones[62];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    for (long long j = 0; j < 60; ++j) {
      long long p = ((long long)1) << j;
      if (a[i] & p) {
        ++ones[j];
      }
    }
  }
  long long res = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 60; ++j) {
      long long p = ((long long)1) << j;
      long long tot_ones = 0;
      if (a[i] & p) {
        --ones[j];
        tot_ones += n - ones[j] - i - 1;
      } else {
        tot_ones += ones[j];
      }
      (res += (tot_ones % MOD * p % MOD) % MOD) %= MOD;
    }
  }
  cout << res << endl;
  return 0;
}
