#include <bits/stdc++.h>
using namespace std;
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  for (T i : v) os << i << ' ';
  return os;
}
template <class T>
ostream& operator<<(ostream& os, const set<T>& v) {
  for (T i : v) os << i << ' ';
  return os;
}
template <class T, class S>
ostream& operator<<(ostream& os, const pair<T, S>& v) {
  os << v.first << ' ' << v.second;
  return os;
}
template <class T, class S>
ostream& operator<<(ostream& os, const map<T, S>& v) {
  for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' ';
  return os;
}
template <class T, class S>
ostream& operator<<(ostream& os, const unordered_map<T, S>& v) {
  for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' ';
  return os;
}
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target( \
    "avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
const long long mod = 1e9 + 7;
long long takemod(long long a) { return ((a % mod) + mod) % mod; }
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long fast_exp(long long base, long long expo) {
  long long res = 1;
  while (expo > 0) {
    if (expo & 1) res = (res * base) % mod;
    base = (base * base) % mod;
    expo >>= 1;
  }
  return res;
}
long long modinv(long long a) { return takemod(fast_exp(takemod(a), mod - 2)); }
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long n;
  cin >> n;
  long long arr[n];
  for (long long i = (0); i < (n); i++) cin >> arr[i];
  long long arr1[n + 1][60];
  memset(arr1, 0, sizeof(arr1));
  long long ans = 0;
  for (long long i = (n - 1); i >= (0); i--) {
    for (long long j = (0); j < (60); j++) {
      if (((arr[i]) & (1LL << j)) == 0) {
        ans = (ans + ((1LL << j) * (arr1[i + 1][j]))) % mod;
        arr1[i][j] = arr1[i + 1][j];
      } else {
        ans = (ans + ((1LL << j) * (n - 1 - i - arr1[i + 1][j]))) % mod;
        arr1[i][j] = 1 + arr1[i + 1][j];
      }
    }
  }
  cout << ans << "\n";
  return 0;
}
