#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
int main() {
  int n;
  cin >> n;
  vector<long long int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  long long dp[n + 1][64];
  memset(dp, 0, sizeof(dp));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 61; j++) {
      if ((v[i] & ((long long)1 << j)) > 0)
        dp[i + 1][j] = (dp[i][j] + 1);
      else
        dp[i + 1][j] = dp[i][j];
    }
  }
  long long s = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 61; j++) {
      if ((v[i] & ((long long)1 << j)) > 0) {
        long long n1 = dp[n][j] - dp[i + 1][j];
        n1 = n - i - 1 - n1;
        s = (s + (n1 * ((long long)1 << j)) % mod) % mod;
      } else {
        long long n1 = dp[n][j] - dp[i + 1][j];
        s = (s + (n1 * ((long long)1 << j)) % mod) % mod;
      }
    }
  }
  cout << s;
}
