#include <bits/stdc++.h>
using namespace std;
template <typename First>
void debug_print_in(First first) {
  cerr << first << endl;
  return;
}
template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest) {
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}
void IN(void) { return; }
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest) {
  cin >> first;
  IN(rest...);
  return;
}
template <typename First>
void OUT(First first) {
  cout << first << endl;
  return;
}
template <typename First, typename... Rest>
void OUT(First first, Rest... rest) {
  cout << first << " ";
  OUT(rest...);
  return;
}
template <class t, class u>
void chmax(t& a, u b) {
  if (a < b) a = b;
};
template <class t, class u>
void chmin(t& a, u b) {
  if (a > b) a = b;
};
int popcount(int t) { return __builtin_popcount(t); }
int popcount(long long t) { return __builtin_popcountll(t); }
template <typename T>
void vec_print(vector<T> VEC) {
  for (long long i = (long long)0; i < (long long)VEC.size(); ++i) {
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};
template <typename T>
void mat_print(vector<vector<T>> MAT) {
  for (long long i = (long long)0; i < (long long)MAT.size(); ++i) {
    for (long long j = (long long)0; j < (long long)MAT[i].size(); ++j) {
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};
constexpr int INF = (1 << 30);
constexpr long long INFLL = 1LL << 62;
constexpr long double EPS = 1e-12;
constexpr long long MOD = (long long)((1E+9) + 7);
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N;
  IN(N);
  vector<long long> A(N);
  for (long long i = (long long)0; i < (long long)N; ++i) IN(A[i]);
  long long ans2 = 0;
  for (long long i = (long long)0; i < (long long)N; ++i) {
    for (long long j = (long long)i + 1; j < (long long)N; ++j) {
      ans2 += (A[i] ^ A[j]);
    }
  }
  cerr << "line " << 92 << " : ";
  debug_print_in(ans2 % MOD);
  ;
  long long ans = 0;
  long long tmp2 = 1;
  for (long long i = (long long)0; i < (long long)61; ++i) {
    long long count = 0;
    for (long long j = (long long)0; j < (long long)N; ++j) {
      count += A[j] % 2;
      A[j] >>= 1;
    }
    long long tmp = (count * (N - count)) % MOD;
    ans += (tmp * tmp2) % MOD;
    tmp2 *= 2;
    tmp2 %= MOD;
    ans %= MOD;
    cerr << "line " << 106 << " : ";
    debug_print_in(i, count);
    ;
  }
  OUT(ans % MOD);
  return 0;
}
