#include <bits/stdc++.h>
using namespace std;
const long long N = 3e5 + 7, MOD = 1e9 + 7;
long long calc[60], a[N];
void solve() {
  long long n;
  cin >> n;
  for (long long i = 0; i < (long long)n; ++i) {
    cin >> a[i];
    for (long long bit = 0; bit < (long long)60; ++bit)
      calc[bit] += bool(a[i] & (1ll << bit));
  }
  long long ans = 0;
  for (long long i = 0; i < (long long)n; ++i)
    for (long long bit = 0; bit < (long long)60; ++bit) {
      calc[bit] -= bool(a[i] & (1ll << bit));
      ans = (ans + ((a[i] & (1ll << bit) ? n - i - 1 - calc[bit] : calc[bit])
                    << bit)) %
            MOD;
    }
  cout << ans;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
