#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int N = 3e5 + 11;
long long a[N], ans;
int n;
inline int A(long long x, long long y) {
  return x + y - (x + y >= mod ? mod : 0);
}
void deal(int b) {
  long long num0 = 0, num1 = 0, base = 1ll << b;
  base %= mod;
  for (int i = n; i >= 1; i--) {
    int fl = a[i] >> b & 1;
    if (fl)
      ans = A(ans, num0 * base), num1++;
    else
      ans = A(ans, num1 * base), num0++;
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
  }
  for (int i = 0; i <= 60; i++) {
    deal(i);
  }
  cout << ans << endl;
  return 0;
}
