#include <bits/stdc++.h>
using namespace std;
const long long int INF = 2e18;
const int inf = 2e9;
const int mod1 = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int n;
  cin >> n;
  vector<long long int> a(n);
  for (long long int &i : a) cin >> i;
  vector<vector<int>> table(63, vector<int>(n));
  for (int bit = 0; bit < 63; bit++) {
    for (int i = 0; i < n; i++) {
      table[bit][i] = ((a[i] & (1LL << bit)) > 0);
      if (i) table[bit][i] += table[bit][i - 1];
    }
  }
  auto add = [&](long long int &a, long long int b) { a = (a + b) % mod1; };
  long long int ans = 0;
  for (int bit = 0; bit < 63; bit++) {
    for (int i = 0; i < n - 1; i++) {
      if (!(a[i] & (1LL << bit)))
        add(ans, (table[bit][n - 1] - table[bit][i - 1]) * 1LL * (1LL << bit) %
                     mod1);
      else
        add(ans, (n - i - (table[bit][n - 1] - table[bit][i - 1])) * 1LL *
                     (1LL << bit) % mod1);
    }
  }
  cout << ans << "\n";
  return 0;
}
