#include <bits/stdc++.h>
using namespace std;
using pi = pair<long, long>;
const long mod = 1e9 + 7;
signed main() {
  long n;
  cin >> n;
  vector<long> a(n);
  for (auto& i : a) cin >> i;
  long suma = 0, land = 0;
  for (auto i : a) suma = (suma + i) % mod;
  long res = 0;
  bool ref = true;
  long base = 1, cnt, ps = 0;
  while (ref) {
    ref = false;
    cnt = ps = 0;
    for (auto& i : a)
      if (i) {
        ref = true;
        if (i & 1) ++cnt;
        i >>= 1;
      }
    ps = cnt * base % mod * cnt % mod;
    land = (land + ps) % mod;
    base <<= 1;
  }
  res = suma % mod * n % mod;
  res = (res - land) % mod;
  if (res < 0) res += mod;
  cout << res % mod << endl;
}
