#include <bits/stdc++.h>
using namespace std;
unsigned long long MOD = 1000000007;
int main() {
  int N;
  cin >> N;
  unsigned long long ans = 0;
  vector<unsigned long long> numbers(N);
  int dp[N][64];
  memset(dp, 0, sizeof(dp));
  for (int i = 0; i < (int)(N); i++) {
    cin >> numbers[i];
  }
  for (int i = 0; i < (int)(64); i++) {
    int count = 0;
    for (int j = (int)(N - 1); j > -1; j--) {
      if (numbers[j] >> i & 1) {
        count++;
      }
      dp[j][i] = count;
    }
  }
  for (int i = 0; i < (int)(N - 1); i++) {
    for (int j = 0; j < (int)(64); j++) {
      unsigned long long count = 0;
      if (numbers[i] >> j & 1) {
        count = (N - i - 1) - dp[i + 1][j];
      } else {
        count = dp[i + 1][j];
      }
      unsigned long long plus = count;
      for (int k = 0; k < (int)(j); k++) plus = plus << 1 % MOD;
      ans += plus;
      ans %= MOD;
    }
  }
  cout << ans << endl;
}
