#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&...tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}
const LL M = 1e9 + 7;
void show(VEC<VEC<int>> A) {
  for (long long i = (0); i < (long long)(A.size()); ++i) {
    for (long long j = (0); j < (long long)(A[i].size()); ++j) {
      cerr << A[i][j] << " ";
    }
    cerr << endl;
  }
  cerr << endl;
}
LL gbit(LL n, LL i) { return (n >> i) & 1; }
int in_contest() {
  LL N;
  cin >> N;
  VEC<LL> A(N);
  for (long long i = (0); i < (long long)(N); ++i) cin >> A[i];
  LL bit_lim = 61;
  VEC<LL> B(bit_lim, 0);
  VEC<VEC<LL>> bit_cs(bit_lim, VEC<LL>(N));
  for (long long bit = (0); bit < (long long)(bit_lim); ++bit) {
    bit_cs[bit][0] = gbit(A[0], bit);
    for (long long i = (1); i < (long long)(N); ++i) {
      bit_cs[bit][i] = gbit(A[i], bit) + bit_cs[bit][i - 1];
    }
  }
  for (long long bit = (0); bit < (long long)(bit_lim); ++bit) {
    for (long long i = (0); i < (long long)(N); ++i) {
      LL one_num_raw = bit_cs[bit][N - 1] - bit_cs[bit][i];
      LL one_num;
      if (gbit(A[i], bit) == 0) {
        one_num = one_num_raw;
      } else {
        one_num = N - i - 1 - one_num_raw;
      }
      B[bit] += one_num;
    }
  }
  LL sum = 0;
  for (long long bit = (0); bit < (long long)(bit_lim); ++bit) {
    LL c = (B[bit] * (1LL << bit)) % M;
    sum = (sum + c) % M;
  }
  cout << sum << endl;
  return 0;
}
int main() {
  ULL N;
  cin >> N;
  VEC<ULL> A(N);
  for (long long i = (0); i < (long long)(N); ++i) cin >> A[i];
  ULL bit_lim = 63;
  VEC<ULL> B(bit_lim, 0);
  for (long long bit = (0); bit < (long long)(bit_lim); ++bit) {
    int zeros = 0;
    int ones = 0;
    for (long long i = (0); i < (long long)(N); ++i) {
      if (gbit(A[i], bit)) {
        ones++;
      }
    }
    zeros = (N - ones);
    B[bit] = zeros * ones;
  }
  ULL sum = 0;
  for (long long bit = (0); bit < (long long)(bit_lim); ++bit) {
    ULL c = (B[bit] * (1ULL << bit)) % M;
    sum = (sum + c) % M;
  }
  cout << sum << endl;
  return 0;
}
