#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const long long INFL = 0x3f3f3f3f3f3f3f3f;
long long a[400000];
long long b[62][400000];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < (n); i++) {
    scanf("%lld", &a[i]);
    for (int j = 0; j < (62); j++) {
      if (a[i] >> j & 1) b[j][i] = 1;
    }
  }
  long long ans = 0;
  for (int i = 0; i < (62); i++) {
    for (int j = n - 2; j >= 0; j--) {
      if (a[j] >> i & 1) {
        ans += (1LL << i) * (n - j - 1 - (b[i][j + 1])) % MOD;
      } else {
        ans += (1LL << i) * (b[i][j + 1]) % MOD;
      }
      ans %= MOD;
      b[i][j] += b[i][j + 1];
    }
  }
  cout << ans << endl;
}
