#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long n, res = 0;
long long a[300010];
long long b[300010][60];
long long mul(long long x, long long y) {
  return ((x % mod) * (y % mod)) % mod;
}
signed main() {
  ios_base ::sync_with_stdio(0);
  cin.tie();
  cout.tie();
  cout << fixed;
  cout << setprecision(15);
  srand(time(NULL));
  cin >> n;
  for (long long i = 0; i < n; i++) cin >> a[i];
  for (long long i = n - 1; i >= 0; i--) {
    for (long long j = 0; j < 60; j++) {
      b[i][j] = b[i + 1][j] + ((a[i] & (1LL << j)) > 0);
    }
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < 60; j++) {
      if (a[i] & (1LL << j)) {
        res = (res + mul(1LL << j, n - i - 1 - b[i + 1][j])) % mod;
      } else {
        res = (res + mul(1LL << j, b[i + 1][j])) % mod;
      }
    }
  }
  cout << res << "\n";
  return 0;
}
