#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
using namespace std;
int cnt[300000][60];
const long long MOD = 1000000007LL;
signed main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    for (int j = 0; j < 60; ++j)
      if (a[i] & (1LL << j)) cnt[i][j] = 1;
  }
  for (int i = 1; i < n; ++i)
    for (int j = 0; j < 60; ++j) cnt[i][j] += cnt[i - 1][j];
  long long ans = 0LL;
  for (int i = 0; i < n - 1; ++i) {
    for (int j = 0; j < 60; ++j) {
      int en = cnt[n - 1][j] - cnt[i][j];
      if (a[i] & (1LL << j)) en = n - 1 - i - en;
      ans += (1LL << j) * en % MOD;
      ans %= MOD;
    }
  }
  cout << ans << endl;
  return 0;
}
