#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
long long modpow(long long a, long long n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1;
  }
  return res;
}
int main() {
  long long n;
  std::cin >> n;
  vector<long long> a(n);
  vector<string> b(n);
  vector<vector<long long>> c(n + 1, vector<long long>(100, 0));
  vector<long long> sum(n + 1);
  sum[0] = 0;
  for (int i = 0; i < n; i++) {
    std::cin >> a[i];
    std::stringstream ss;
    ss << static_cast<std::bitset<60>>(a[i]);
    string x_bin = ss.str();
    reverse(x_bin.begin(), x_bin.end());
    b[i] = x_bin;
    for (int j = 0; j < 60; j++) {
      c[i + 1][j] = c[i][j];
      if (b[i][j] == '1') {
        c[i + 1][j]++;
      }
    }
    sum[i + 1] = sum[i] + a[i];
  }
  long long mod = 1e9 + 7;
  long long res = 0;
  for (int i = 0; i < n - 1; i++) {
    res += a[i] % mod * (n - i - 1) % mod + (sum[n] - sum[i + 1]) % mod;
    res %= mod;
    for (int j = 0; j < 60; j++) {
      if (b[i][j] == '1') {
        res -= (modpow(2, j) % mod * (c[n][j] - c[i + 1][j])) % mod * 2 % mod;
        res += mod;
        res %= mod;
      }
    }
  }
  std::cout << res << std::endl;
}
