#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const long long longinf = 1LL << 60;
const long long mod = 1e9 + 7;
const long long mod2 = 998244353;
const long double eps = 1e-10;
template <typename T1, typename T2>
inline void chmin(T1 &a, T2 b) {
  if (a > b) a = b;
}
template <typename T1, typename T2>
inline void chmax(T1 &a, T2 b) {
  if (a < b) a = b;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<long long> A(n);
  for (int i = (int)(0); i < (int)(n); i++) cin >> A[i];
  vector<vector<int>> B(n + 1, vector<int>(60));
  long long ans = 0;
  for (int i = (int)(0); i < (int)(n); i++) {
    for (int j = (int)(0); j < (int)(60); j++) {
      (ans += ((A[i] >> j) & 1 ? i - B[i][j] : B[i][j]) * (1LL << j % mod)) %=
          mod;
      B[i + 1][j] = B[i][j] + ((A[i] >> j) & 1);
    }
  }
  cout << ans << '\n';
  return 0;
}
