#include <bits/stdc++.h>
using namespace std;
long a[300010], s[64][300010][2];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    for (int j = 0; j < 61; ++j) {
      int k = (a[i] >> j) & 1;
      if (k == 0) {
        s[j][i + 1][0] = s[j][i][0] + 1;
        s[j][i + 1][1] = s[j][i][1];
      } else {
        s[j][i + 1][0] = s[j][i][0];
        s[j][i + 1][1] = s[j][i][1] + 1;
      }
    }
  }
  const long mod = 1e9 + 7;
  long res = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 61; ++j) {
      long t = 0;
      int x = (a[i] >> j) & 1;
      t += s[j][n][!x] - s[j][i][!x];
      t %= mod;
      for (int k = 0; k < j; ++k) (t *= 2) %= mod;
      (res += t) %= mod;
    }
  }
  cout << res << endl;
}
