#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vvp = vector<vector<pair<int, int>>>;
template <typename T>
using ve = vector<T>;
template <typename T>
using pq2 = priority_queue<T>;
template <typename T>
using pq1 = priority_queue<T, vector<T>, greater<T>>;
template <typename T>
bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vl A(N);
  for (int i = 0; i < (N); i++) {
    cin >> A[i];
  };
  vvl B(N, vl(61, 0)), C(N, vl(61, 0));
  for (int i = 0; i < (N); i++) {
    bitset<61> b(A[i]);
    for (int j = 0; j < (61); j++)
      if (b[j] == 1) B[i][j] = 1;
  }
  for (int i = 0; i < (61); i++) C[0][i] = B[0][i];
  for (int i = (1); i < (N); i++)
    for (int j = 0; j < (61); j++) C[i][j] = C[i - 1][j] + B[i][j];
  ll aa = 1;
  ll ans = 0;
  for (int i = 0; i < (N - 1); i++) {
    aa = 1;
    for (int j = 0; j < (61); j++) {
      if (B[i][j] == 1) {
        ans += (((ll)(N - i - 1) - (C[N - 1][j] - C[i][j])) * aa % 1000000007) %
               1000000007;
        ans %= 1000000007;
      } else {
        ans += ((C[N - 1][j] - C[i][j]) * aa % 1000000007) % 1000000007;
        ans %= 1000000007;
      }
      aa *= 2;
    }
  }
  cout << ans % 1000000007 << endl;
  return 0;
}
