#include <bits/stdc++.h>
using namespace std;
using namespace std;
int INF = 1e9;
int mod = 1e9 + 7;
long long modpow(long long x, long long y) {
  if (y == 0) return 1;
  if (y % 2) return x * modpow(x, y - 1) % mod;
  long long res = modpow(x, y / 2);
  return res * res % mod;
}
struct LazySegmentTree {
 private:
  int n;
  vector<int> node, lazy;

 public:
  LazySegmentTree(vector<int> v) {
    int sz = (int)v.size();
    n = 1;
    while (n < sz) n *= 2;
    node.resize(2 * n - 1);
    lazy.resize(2 * n - 1, 0);
    for (int i = 0; i < sz; i++) node[i + n - 1] = v[i];
    for (int i = n - 2; i >= 0; i--)
      node[i] = node[i * 2 + 1] + node[i * 2 + 2];
  }
  void eval(int k, int l, int r) {
    if (lazy[k] != 0) {
      node[k] += lazy[k];
      if (r - l > 1) {
        lazy[2 * k + 1] += lazy[k] / 2;
        lazy[2 * k + 2] += lazy[k] / 2;
      }
      lazy[k] = 0;
    }
  }
  void add(int a, int b, int x, int k = 0, int l = 0, int r = -1) {
    if (r < 0) r = n;
    eval(k, l, r);
    if (b <= l || r <= a) return;
    if (a <= l && r <= b) {
      lazy[k] += (r - l) * x;
      eval(k, l, r);
    } else {
      add(a, b, x, 2 * k + 1, l, (l + r) / 2);
      add(a, b, x, 2 * k + 2, (l + r) / 2, r);
      node[k] = node[2 * k + 1] + node[2 * k + 2];
    }
  }
  int getsum(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r < 0) r = n;
    if (b <= l || r <= a) return 0;
    eval(k, l, r);
    if (a <= l && r <= b) return node[k];
    int vl = getsum(a, b, 2 * k + 1, l, (l + r) / 2);
    int vr = getsum(a, b, 2 * k + 2, (l + r) / 2, r);
    return vl + vr;
  }
};
int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<vector<bool>> bit_a(n, vector<bool>(60, 0));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 60; j++) {
      bit_a[i][j] = ((a[i] >> j) & 1);
    }
  }
  long long ans = 0;
  LazySegmentTree seg(vector<int>(120, 0));
  for (int i = n - 1; i > 0; i--) {
    for (int j = 0; j < 60; j++) {
      if ((a[i] >> j) & 1)
        seg.add(j + 60, j + 61, 1);
      else
        seg.add(j, j + 1, 1);
    }
    for (int j = 0; j < 60; j++) {
      if ((a[i - 1] >> j) & 1) {
        ans += modpow(2, j) * seg.getsum(j, j + 1) % mod;
        ans %= mod;
      } else {
        ans += modpow(2, j) * seg.getsum(j + 60, j + 61) % mod;
        ans %= mod;
      }
    }
  }
  cout << ans << endl;
}
