#include <bits/stdc++.h>
using namespace std;
long long F[2100010];
long long Mul(long long a, long long b) {
  return ((a % 1000000007) * (b % 1000000007)) % 1000000007;
}
void fact(void) {
  F[0] = 1;
  F[1] = 1;
  for (long long i = 2; i <= 2100000; i++) {
    F[i] = Mul(i, F[i - 1]);
  }
}
long long square(long long x) { return (x * x) % 1000000007; }
long long power(long long x, long long y) {
  if (y == 0)
    return 1;
  else if (y == 1)
    return x % 1000000007;
  else if (y % 2 == 0)
    return square(power(x, y / 2)) % 1000000007;
  else
    return square(power(x, y / 2)) * x % 1000000007;
}
long long Div(long long a, long long b) {
  return Mul(a, power(b, 1000000007 - 2));
}
long long P(long long n, long long r) {
  if (n < r || n < 0 || r < 0) return 0;
  return Div(F[n], F[n - r]);
}
long long C(long long n, long long r) {
  if (n < r || n < 0 || r < 0) return 0;
  long long ret;
  ret = Div(F[n], Mul(F[n - r], F[r]));
  return ret;
}
long long H(long long n, long long r) {
  if (n == 0 && r == 0) return 1;
  return C(n + r - 1, r);
}
long long K[64];
signed main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N;
  cin >> N;
  long long A[30010];
  for (long long i = 0; i < N; i++) cin >> A[i];
  long long sum = 0;
  for (long long i = 0; i < N; i++) {
    long long num = A[i];
    long long cnt = 0;
    while (num > 0) {
      K[cnt] += num % 2;
      num /= 2;
      cnt++;
    }
  }
  long long ans = 0;
  for (long long i = 0; i < N - 1; i++) {
    long long cnt = 0;
    for (long long j = 0; j < 62; j++) {
      if (A[i] % 2 == 1) {
        ans = (ans + Mul((1LL << j), (N - i) - K[j])) % 1000000007;
      } else {
        ans = (ans + Mul((1LL << j), K[j])) % 1000000007;
      }
      K[j] -= A[i] % 2;
      A[i] /= 2;
    }
  }
  cout << ans << endl;
  return 0;
}
