#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 4;
const int mod = 1e9 + 7;
long long n, pre[70][N], a, dizi[N], ans;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> dizi[i];
  }
  for (long long i = 0; i < 64; i++) {
    pre[i][0] = 0;
    for (long long j = 1; j <= n; j++) {
      pre[i][j] =
          (pre[i][j - 1] % mod) + ((dizi[j] & ((long long)1 << i)) != 0);
      pre[i][j] += mod;
      pre[i][j] %= mod;
    }
  }
  for (long long i = 0; i < 64; i++) {
    for (long long j = 1; j < n; j++) {
      if ((dizi[j] & ((long long)1 << i)) != 0)
        ans += (((n - (pre[i][n] - pre[i][j] + j)) % mod) *
                (((long long)1 << i) % mod)) %
                   mod +
               mod;
      else
        ans += (((pre[i][n] - pre[i][j] + mod) % mod) *
                ((((long long)1 << i) + mod) % mod)) %
                   mod +
               mod;
      ans += mod;
      ans %= mod;
    }
  }
  cout << ans << '\n';
  return 0;
}
