#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  ll A[1000] = {};
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
  }
  int cumsum[1000][60];
  for (int i = 0; i < 60; i++) {
    cumsum[0][i] = 0;
  }
  for (int i = 1; i <= N; i++) {
    for (int j = 0; j < 60; j++) {
      cumsum[i][j] = cumsum[i - 1][j] + (A[i] >> j & 1l);
    }
  }
  ll res = 0;
  for (int i = 1; i < N; i++) {
    for (int j = 0; j < 60; j++) {
      ll tmp;
      if (A[i] >> j & 1l) {
        tmp = (1 << j) % mod * (N - (cumsum[N][j] - cumsum[i][j]) - i);
        res = (res + tmp) % mod;
      } else {
        tmp = (1 << j) % mod * (cumsum[N][j] - cumsum[i][j]);
        res = (res + tmp) % mod;
      }
      res %= mod;
    }
  }
  cout << res << "\n";
}
