#include <bits/stdc++.h>
using namespace std;
long long bS(long long l, long long r, long long x, vector<long long> arr) {
  while (l <= r) {
    long long m = l + (r - l) / 2;
    if (arr[m] == x) return m;
    if (arr[m] < x)
      l = m + 1;
    else
      r = m - 1;
  }
  return -1;
}
void primeFactors(long long n) {
  while (n % 2 == 0) {
    n = n / 2;
  }
  for (long long i = 3; i <= sqrt(n); i += 2) {
    while (n % i == 0) {
      n = n / i;
    }
  }
  if (n > 2) cout << n << " ";
}
long long power(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long modulo(long long a, long long b) {
  long long c = a % b;
  return (c < 0) ? c + b : c;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  while (t--) {
    long long n;
    cin >> n;
    vector<long long> vec(n);
    for (auto &it : vec) cin >> it;
    ;
    vector<vector<long long> > ans(n, vector<long long>(63, 0));
    for (long long i = 0; i < n; i++) {
      for (long long j = 0; j < 63; j++) {
        if (vec[i] & 1LL << j) ans[i][j] = 1;
      }
    }
    for (long long i = 0; i < 63; i++) {
      for (long long j = 1; j < n; j++) {
        ans[j][i] += ans[j - 1][i];
      }
    }
    vector<long long> count(63, 0);
    for (long long i = 0; i < n; i++) {
      for (long long j = 0; j < 63; j++) {
        if (vec[i] & 1LL << j)
          count[j] += n - 1 - i - ans[n - 1][j] + ans[i][j];
        else
          count[j] += ans[n - 1][j] - ans[i][j];
      }
    }
    long long sum = 0;
    for (long long i = 0; i < 63; i++) {
      sum += ((count[i] % 1000000007) * (1 << i) % 1000000007) % 1000000007;
      sum %= 1000000007;
    }
    cout << sum << endl;
  }
  cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
  return 0;
}
