#include <bits/stdc++.h>
using namespace std;
typedef struct datum_name {
  int x;
  int y;
  int whosay;
  bool operator==(const datum_name& data) const {
    return (x == data.x && y == data.y);
  }
} datum;
bool cmp_who(const datum& left, const datum& right) {
  return left.whosay < right.whosay;
}
vector<bool> seen;
vector<int> depth;
void dfs(const vector<vector<int>>& G, int v, int depth_num) {
  seen[v] = true;
  depth[v] = depth_num;
  for (auto next_v : G[v]) {
    if (seen[next_v]) continue;
    dfs(G, next_v, depth_num + 1);
  }
}
int main() {
  int N;
  cin >> N;
  vector<int64_t> array;
  for (int i = 0; i < N; i++) {
    int64_t tmp;
    cin >> tmp;
    array.push_back(tmp);
  }
  vector<int> one_num;
  one_num.resize(61);
  for (int order = 0; order < 61; order++) {
    for (int i = 0; i < N; i++) {
      if (array[i] & ((int64_t)(1) << order)) {
        one_num[order] += 1;
      }
    }
  }
  vector<int64_t> ans_one_num;
  ans_one_num.resize(61);
  for (int order = 0; order < 61; order++) {
    for (int j = 0; j < N; j++) {
      if (array[j] & ((int64_t)(1) << order)) {
        one_num[order] -= 1;
        ans_one_num[order] += (int64_t)((N - j - 1) - one_num[order]);
      } else {
        ans_one_num[order] += (int64_t)(one_num[order]);
      }
    }
  }
  int64_t ans = 0;
  for (int order = 0; order < 61; order++) {
    int64_t order_value = ((int64_t)(1) << order) % (1000000000 + 7);
    ans += ans_one_num[order] * order_value;
    ans = ans % (1000000000 + 7);
  }
  cout << ans << endl;
  return 0;
}
