#include <bits/stdc++.h>
using namespace std;
long long bit[65];
int main() {
  long long n;
  cin >> n;
  long long a[n];
  for (long long i = 0; i < n; i++) cin >> a[i];
  long long sum = 0, ans = 0;
  for (long long i = 1; i < n; i++) {
    sum += a[i - 1];
    long long s = sum;
    for (long long j = 0; j <= 60; j++) {
      if ((a[i - 1] & (1LL << j))) bit[j]++;
      if (a[i] & (1LL << j)) s += (1LL << j) * (i - bit[j] - bit[j]);
      s %= 1000000007LL;
    }
    ans += s;
    ans %= 1000000007LL;
  }
  cout << ans << endl;
  return 0;
}
