#include <bits/stdc++.h>
using namespace std;
long long n, a[300001], ans, sum[64];
signed main() {
  std::ios::sync_with_stdio(false);
  cin >> n;
  for (long long i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  for (long long i = n; i; --i) {
    for (long long j = 0; j < 63; ++j) {
      if ((a[i] >> j) & 1) {
        ans = (ans + ((n - i - sum[j]) << j)) % 1000000007;
        ++sum[j];
      } else {
        ans = (ans + ((sum[j]) << j)) % 1000000007;
      }
    }
  }
  cout << ans;
  return 0;
}
