#include <bits/stdc++.h>
using namespace std;
void generate(vector<vector<int> > &comb, int n, vector<int> &curr) {
  if (curr.size() == n) {
    comb.push_back(curr);
    return;
  }
  curr.push_back(1);
  generate(comb, n, curr);
  curr.pop_back();
  curr.push_back(0);
  generate(comb, n, curr);
  curr.pop_back();
  return;
}
int correct(vector<int> &v, vector<vector<pair<int, int> > > &comb) {
  for (int i = 0; i < (int)v.size(); i++) {
    if (v[i] == 1) {
      for (int j = 0; j < (int)comb[i].size(); j++) {
        pair<int, int> temp = comb[i][j];
        if (temp.second == 1) {
          if (v[temp.first - 1] == 0) return 0;
        } else {
          if (v[temp.first - 1] == 1) return 0;
        }
      }
    }
  }
  return 1;
}
int main() {
  int n, i, j;
  cin >> n;
  long long int a[n];
  for (i = 0; i < n; i++) cin >> a[i];
  int mem[n + 1][64];
  memset(mem, 0, sizeof(mem));
  for (i = 0; i < n; i++) {
    for (j = 0; j < 64; j++) {
      long long num = (1LL) << j;
      mem[i + 1][j] = mem[i][j] + ((num & a[i]) > 0);
    }
  }
  long long ans = 0;
  for (i = 0; i < n; i++) {
    for (j = 0; j < 62; j++) {
      long long now = (1LL) << j;
      if ((now & a[i]) == 0) {
        ans = (ans + (mem[n][j] - mem[i + 1][j]) * ((1LL) << j)) % 1000000007;
      } else {
        ans = (ans + (n - i - 1 - (mem[n][j] - mem[i + 1][j])) * ((1LL) << j)) %
              1000000007;
      }
    }
  }
  cout << ans << endl;
}
