#include <bits/stdc++.h>
using namespace std;
long long a[300005], b[300005][69];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long ans = 0;
  for (int i = 0; i <= 64; i++) {
    b[n][i] = 0;
  }
  for (long long i = n - 1; i >= 0; i--) {
    for (long long j = 0; j < 64; j++) {
      if ((a[i] & (1ll << j)) != 0) {
        b[i][j] = b[i + 1][j] + 1;
      } else {
        b[i][j] = b[i + 1][j];
      }
    }
  }
  for (long long i = 0; i < n - 1; i++) {
    for (long long j = 0; j < 64; j++) {
      long long x = (1ll << j);
      if ((x & a[i]) != 0) {
        ans += (x * (n - 1 - i - b[i + 1][j]));
      } else {
        ans += (x * b[i + 1][j]);
      }
      ans = ans % 1000000007;
      if (ans < 0) ans += 1000000007;
    }
  }
  cout << ans;
}
