#include <bits/stdc++.h>
using namespace std;
vector<int64_t> bit(int64_t a) {
  vector<int64_t> res(61);
  for (int i = 0; i < res.size(); i++) {
    if (a % 2 == 1) {
      res.at(i) = 1;
    }
    a /= 2;
  }
  return res;
}
int64_t tib(vector<int64_t> a) {
  int64_t res = 0;
  int64_t po = 1;
  for (int i = 0; i < a.size(); i++) {
    res += po * a.at(i);
    po *= 2;
  }
  return res;
}
vector<int64_t> sumsum(vector<int64_t> a, vector<int64_t> ch, int i) {
  vector<int64_t> res(ch.size() + i);
  for (int j = 0; j < res.size(); j++) {
    if (j < i) {
      res.at(j) = a.at(j);
    } else if (j < a.size()) {
      res.at(j) = a.at(j) + ch.at(j - i);
    } else {
      res.at(j) = ch.at(j - i);
    }
  }
  return res;
}
vector<int64_t> rebit(vector<int64_t> a) {
  vector<int64_t> ch;
  int64_t A;
  int64_t size = a.size();
  for (int i = 0; i < size; i++) {
    A = a.at(i);
    ch = bit(a.at(i));
    a = sumsum(a, ch, i);
    a.at(i) -= A;
  }
  return a;
}
int64_t q(vector<vector<int64_t>> X, int64_t i) {
  int64_t a, b;
  a = 0;
  b = 0;
  for (int j = 0; j < X.size(); j++) {
    if (X.at(j).at(i) == 1) {
      a++;
    } else {
      b++;
    }
  }
  return a * b;
}
vector<int64_t> p(vector<vector<int64_t>> X) {
  vector<int64_t> res(X.at(0).size());
  for (int i = 0; i < X.size(); i++) {
    res.at(i) = q(X, i);
  }
  return res;
}
int main() {
  int64_t N;
  cin >> N;
  vector<int64_t> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  int64_t m = pow(10, 9) + 7;
  vector<vector<int64_t>> X(N);
  for (int i = 0; i < N; i++) {
    X.at(i) = bit(A.at(i));
  }
  vector<int64_t> res = p(X);
  cout << tib(rebit(res)) % m << endl;
}
