#include <bits/stdc++.h>
using namespace std;
template <class A, class B>
ostream &operator<<(ostream &out, const pair<A, B> &a) {
  return out << "(" << a.first << "," << a.second << ")";
}
template <class A>
ostream &operator<<(ostream &out, const vector<A> &a) {
  for (const A &it : a) out << it << " ";
  return out;
}
template <class A, class B>
istream &operator>>(istream &in, pair<A, B> &a) {
  return in >> a.first >> a.second;
}
template <class A>
istream &operator>>(istream &in, vector<A> &a) {
  for (A &i : a) in >> i;
  return in;
}
long long poww(const long long &a, long long b,
               const long long &m = 1000000007) {
  if (b == 0) return 1;
  long long x = poww(a, b / 2, m);
  x = x * x % m;
  if (b & 1) x = x * a % m;
  return x;
}
long long ceil(const long long &a, const long long &b) {
  return (a + b - 1) / b;
}
long long n;
long long v[300005];
long long suf[64][300005][2];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> v[i];
  for (long long i = 0; i < 64; i++) {
    for (long long j = n; j >= 1; j--) {
      suf[i][j][1] = suf[i][j + 1][1] + ((v[j] >> i) & 1);
      suf[i][j][0] = suf[i][j + 1][0] + (1 - ((v[j] >> i) & 1));
    }
  }
  long long ans = 0;
  for (long long i = 0; i < 64; i++) {
    for (long long j = n; j >= 1; j--) {
      long long z = suf[i][j + 1][0];
      long long o = suf[i][j + 1][1];
      if ((v[j] >> i) & 1) {
        ans += poww(2, i) * z % 1000000007;
      } else {
        ans += poww(2, i) * o % 1000000007;
      }
      ans %= 1000000007;
    }
  }
  cout << ans;
}
