#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<vector<int> > bt(61, vector<int>(n, 0));
  for (long long i = 0; i < n; i++) {
    long long tmp = a[i];
    for (long long j = 0; j < 61; j++) {
      bt[j][i] = bt[j][i - 1] * (i > 0) + (tmp % 2);
      tmp /= 2;
    }
  }
  long long ans = 0;
  for (long long i = 0; i < n - 1; i++) {
    long long p = 1;
    long long tmp = a[i];
    for (long long j = 0; j < 61; j++) {
      if (tmp % 2) {
        ans += (((n - i - 1) - (bt[j][n - 1] - bt[j][i])) * p) % 1000000007;
        ans %= 1000000007;
      } else {
        ans += ((bt[j][n - 1] - bt[j][i]) * p) % 1000000007;
        ans %= 1000000007;
      }
      p *= 2;
      tmp /= 2;
    }
  }
  cout << ans << endl;
}
