#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-6;
const unsigned long long hashp = 1e7 + 19;
const long long INF = 0x3f3f3f3f3f3f3f3fll;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int maxn = 3e5 + 100;
long long sum[maxn][64];
long long a[maxn];
void solve() {
  int n;
  scanf("%d", &n);
  for (int i = 1; (i) <= (n); i++) scanf("%lld", &a[i]);
  for (int i = n; i; i--) {
    for (int j = 62; ~j; j--) {
      sum[i][j] = sum[i + 1][j];
      if (a[i] & (1ll << j)) sum[i][j]++;
    }
  }
  int ans = 0;
  for (int i = 1; (i) <= (n - 1); i++) {
    for (int j = 62; ~j; j--) {
      if (a[i] & (1ll << j))
        ans = (ans + 1ll * (n - i - sum[i + 1][j]) * (1ll << j) % mod) % mod;
      else {
        ans = (ans + 1ll * sum[i + 1][j] * (1ll << j) % mod) % mod;
      }
    }
  }
  cout << ans << endl;
}
int main() {
  solve();
  return 0;
}
