#include <bits/stdc++.h>
using namespace std;
struct IoSetup {
  IoSetup() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} IoSetup;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 998244353;
static const signed int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
static const signed int dy[] = {0, -1, 0, 1, -1, 1, -1, 1};
bool inside(int x, int y, int w, int h) {
  return (x >= 0 && y >= 0 && x < w && y < h);
}
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) return (a = b, 1);
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) return (a = b, 1);
  return 0;
}
long long sum[300300][70];
signed main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 60; j++) {
      sum[i + 1][j] = sum[i][j] + !!(a[i] & (1LL << j));
    }
  }
  long long ans = 0;
  long long t;
  for (int i = 0; i < n; i++) {
    for (long long j = 0; j < 60; j++) {
      if (a[i] & (1LL << j)) {
        t = (n - sum[n][j]) * (1LL << j);
        t %= SMOD;
      } else {
        t = sum[n][j] * (1LL << j);
        t %= SMOD;
      }
      ans += t;
      ans %= SMOD;
    }
  }
  cout << ans / 2 << endl;
  return 0;
}
