#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
void solve() {
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  long long sum = 0;
  vector<long long> cnt(61);
  for (int i = n - 1; i >= 0; i--) {
    long long v = a[i];
    for (int bit = 0; bit < 61; bit++) {
      int b = (v & (1LL << bit) ? 1 : 0);
      if (b == 0)
        sum = (sum % mod + (cnt[bit] % mod * (1LL << bit) % mod) % mod) % mod;
      else {
        sum = (sum % mod +
               ((n - i - 1 - cnt[bit]) % mod * (1LL << bit) % mod) % mod) %
              mod;
        cnt[bit]++;
      }
    }
  }
  cout << sum;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int test_case = 1;
  for (int i = 1; i <= test_case; i++) {
    solve();
  }
}
