#include <bits/stdc++.h>
using namespace std;
vector<string> split(const string &s, char c) {
  vector<string> v;
  stringstream second(s);
  string x;
  while (getline(second, x, c)) v.emplace_back(x);
  return move(v);
}
void err(vector<string>::iterator it) {}
template <typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
  cout << it->substr((*it)[0] == ' ', it->length()) << " = " << a << ", ";
  err(++it, args...);
}
int ini() {
  int x;
  scanf("%d", &x);
  return x;
}
long long inl() {
  long long x;
  scanf("%lld", &x);
  return x;
}
double ind() {
  double x;
  scanf("%lf", &x);
  return x;
}
int set_1(int n, int pos) { return n = (n | (1 << pos)); }
int reset_0(int n, int pos) { return n = n & ~(1 << pos); }
bool check_bit(int n, int pos) { return n = n & (1 << pos); }
bool check_bitl(long long n, int pos) { return n = n & (1ll << pos); }
int dx[8] = {1, 0, -1, 0, -1, -1, 1, 1};
int dy[8] = {0, 1, 0, -1, -1, 1, -1, 1};
const int N = (int)1e6 + 5;
const long long M = (long long)1e9 + 7;
const double pi = 2 * acos(0.0);
const double eps = 1e-9;
long long v[64];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1, te = 0;
  while (t--) {
    long long n;
    cin >> n;
    long long res = 0ll;
    for (long long j = 0; j < n; j++) {
      long long x;
      cin >> x;
      for (long long i = 0; i < 60; i++) {
        int bit = (x >> i) & 1;
        if (bit) {
          res = (res + ((j - v[i]) * (1ll << i) % M) % M) % M;
          v[i]++;
        } else {
          res = (res + (v[i] * (1ll << i) % M) % M) % M;
        }
      }
    }
    printf("%lld\n", res % M);
  }
  return 0;
}
