#include <bits/stdc++.h>
using namespace std;
long long INF = LONG_LONG_MAX;
long long mod = 1000000000 + 7;
template <typename T, typename L>
void read(vector<T>& _data, L& _size, bool _shift) {
  _data.resize(_size + (long long)_shift);
  for (long long i = (long long)_shift; i < _size + (long long)_shift; i++)
    cin >> _data[i];
}
template <typename T, typename L>
void read(vector<vector<T>>& _data, L& _rows, L& _cols, bool _shiftRows,
          bool _shiftCols) {
  _data.resize(_rows + (long long)_shiftRows);
  for (long long i = 0; i < _rows + (long long)_shiftRows; i++)
    _data[i].resize(_cols + (long long)_shiftCols);
  for (long long i = (long long)_shiftRows; i < _rows + (long long)_shiftRows;
       i++)
    for (long long j = (long long)_shiftCols; j < _cols + (long long)_shiftCols;
         j++)
      cin >> _data[i][j];
}
template <typename T>
void write(vector<T>& _data, bool _shift) {
  for (long long i = (long long)_shift; i < _data.size(); i++)
    cout << _data[i] << " ";
  cout << endl;
}
void solve() {
  long long n;
  cin >> n;
  vector<long long> a;
  read(a, n, 0);
  vector<long long> zeroes(60, 0);
  vector<long long> ones(60, 0);
  long long m = pow(2, 60);
  long long ans = 0;
  for (auto x : a) {
    long long y = 1;
    long long i = 0;
    while (y < m) {
      if (y & x) {
        ans += zeroes[i] * y;
        ones[i]++;
      } else {
        ans += ones[i] * y;
        zeroes[i]++;
      }
      i++;
      y *= 2;
      ans = ans % mod;
    }
  }
  cout << ans << endl;
}
int main() {
  bool _multipleTestCases = false;
  if (_multipleTestCases) {
    long long t;
    cin >> t;
    while (t--) solve();
  } else {
    solve();
  }
  return 0;
}
