#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const double EPS = 1e-7;
const int INF = 1 << 30;
const long long int LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long int n;
  cin >> n;
  vector<long long int> a(n);
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<vector<long long int>> digit(60, vector<long long int>(n, 0));
  for (long long int d = 0; d < 60; d++) {
    for (long long int i = 0; i < n; i++) {
      if (a[i] & (1LL << d)) {
        digit[d][i] = 1;
      }
    }
  }
  vector<vector<long long int>> digitsum = digit;
  for (long long int i = 0; i < 60; i++) {
    for (long long int j = 1; j < n; j++) {
      digitsum[i][j] += digitsum[i][j - 1];
    }
  }
  long long int ans = 0;
  for (long long int d = 0; d < 60; d++) {
    for (long long int i = 0; i < n - 1; i++) {
      int cnt = digitsum[d][n - 1] - digitsum[d][i];
      if (digit[d][i] == 1) {
        cnt = n - i - 1 - cnt;
      }
      ans += cnt * (1LL << d) % MOD;
      ans %= MOD;
    }
  }
  cout << ans << "\n";
}
