#include <bits/stdc++.h>
using namespace std;
template <typename T>
void Debug(T begin, T end);
int si();
long long sl();
string ss(int);
double sf();
long double slf();
void pi(int, char = '\n');
void pl(long long, char = '\n');
void pf(double, char = '\n');
void plf(long double, char = '\n');
void ps(string, char = '\n');
long long russian(long long, long long, long long);
long long fastpow(long long, long long, long long);
long long slowpow(long long, long long, long long);
long long _gcd(long long, long long);
long long _lcm(long long, long long);
long long extgcd(long long, long long, long long&, long long&);
long long _inv(long long, long long);
const int INF = 1e9;
const long long LINF = 1e18;
const int N = 3e5 + 7;
const long long M = 1e9 + 7;
int Suf[N][60];
long long A[N];
int main() {
  int n = si();
  for (int i = 0; i < n; ++i) A[i] = sl();
  for (int i = n - 1; i >= 0; --i) {
    long long a = A[i];
    for (int j = 0; j < 60; ++j) {
      Suf[i][j] = Suf[i + 1][j];
      if (a & (1LL << j)) ++Suf[i][j];
    }
  }
  long long sum = 0;
  for (int i = 0; i < n - 1; ++i) {
    long long a = A[i];
    for (int j = 0; j < 60; ++j) {
      int cnt = (a & (1LL << j)) ? n - 1 - i - Suf[i + 1][j] : Suf[i + 1][j];
      sum = (sum + long long(cnt) * (1LL << j) % M) % M;
    }
  }
  pl(sum);
  return 0;
}
template <typename T>
void Debug(T begin, T end) {
  printf("\nDEBUG:\n");
  while (begin != end) printf("%d ", *begin), begin++;
  printf("\n\n");
}
template <typename T>
T scanf_t(string s) {
  T a;
  scanf(s.c_str(), &a);
  return a;
}
template <typename T>
void printf_t(T a, string s, char end_l) {
  s.push_back(end_l);
  printf(s.c_str(), a);
}
int si() { return scanf_t<int>("%d"); }
long long sl() { return scanf_t<long long>("%lld"); }
double sf() { return scanf_t<double>("%f"); }
long double slf() { return scanf_t<long double>("%Lf"); }
void pi(int a, char end_l) { printf_t<int>(a, "%d", end_l); }
void pl(long long a, char end_l) { printf_t<long long>(a, "%lld", end_l); }
void pf(double a, char end_l) { printf_t<double>(a, "%lf", end_l); }
void plf(long double a, char end_l) { printf_t<long double>(a, "%Lf", end_l); }
void ps(string a, char end_l) {
  string s = "%s";
  s.push_back(end_l);
  printf(s.c_str(), a.c_str());
}
string ss(int NN) {
  char T[NN];
  scanf("%s", T);
  return (string)T;
}
long long fastpow(long long a, long long k, long long m) {
  long long r = 1LL;
  while (k) {
    if (k & 1LL) r = (r * a) % m;
    a = (a * a) % m;
    k >>= 1LL;
  }
  return r;
}
long long slowpow(long long a, long long k, long long m) {
  long long r = 1LL;
  while (k) {
    if (k & 1LL) r = russian(r, a, m);
    a = russian(a, a, m);
    k >>= 1LL;
  }
  return r;
}
long long russian(long long a, long long k, long long m) {
  long long r = 0LL;
  while (k) {
    if (k & 1LL) r = (r + a) % m;
    a = (a + a) % m;
    k >>= 1LL;
  }
  return r;
}
long long _gcd(long long a, long long b) {
  while (b) swap(a %= b, b);
  return a;
}
long long _lcm(long long a, long long b) { return a / _gcd(a, b) * b; }
long long extgcd(long long a, long long b, long long& k, long long& l) {
  if (b == 0) {
    k = 1;
    l = 0;
    return a;
  }
  long long res = extgcd(b, a % b, l, k);
  l -= a / b * k;
  return res;
}
long long _inv(long long a, long long p) { return fastpow(a, p - 2, p); }
