#include <bits/stdc++.h>
using namespace std;
class DXorSum4 {
 public:
  int dy[4] = {-1, 1, 0, 0};
  int dx[4] = {0, 0, 1, -1};
  void solve(std::istream& in, std::ostream& out) {
    int N;
    in >> N;
    vector<long long> A(N);
    vector<int> digit_zero(60, 0);
    vector<int> digit_one(60, 0);
    for (long long i = 0; i < (long long)(N); i++) {
      in >> A[i];
    }
    for (long long i = 0; i < (long long)(N); i++) {
      for (long long j = 0; j < (long long)(60); j++) {
        if (A[i] >> j & 1) {
          digit_one[j]++;
        } else {
          digit_zero[j]++;
        }
      }
    }
    long long ans = 0;
    for (long long i = 0; i < (long long)(N); i++) {
      for (long long j = 0; j < (long long)(60); j++) {
        if (A[i] >> j & 1) {
          ans += (1L << j) * digit_zero[j];
          digit_one[j]--;
          ans %= long long(1e9 + 7);
        } else {
          ans += (1L << j) * digit_one[j];
          digit_zero[j]--;
          ans %= long long(1e9 + 7);
        }
      }
    }
    out << ans << endl;
  }
};
int main() {
  ios::sync_with_stdio(false);
  DXorSum4 solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}
