#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long int n;
  cin >> n;
  vector<long long int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  long long int data[100];
  for (int i = 0; i < 100; i++) data[i] = 0;
  long long int sum = 0;
  for (long long int i = 0; i < n; i++) {
    if (0) cout << endl << "now=" << a[i] << endl;
    if (i != 0) {
      long long int next = a[i];
      long long int size = i;
      long long int two = 1;
      for (long long int bit = 0; bit < 61; bit++) {
        if (0) cout << "sum=" << sum << endl;
        if (next & (1LL << bit)) {
          if (0)
            cout << "ON"
                 << " bit=" << bit << " size-data[bit]=" << size - data[bit]
                 << endl;
          sum += two * (size - data[bit]);
        } else {
          if (0)
            cout << " OFF"
                 << " bit=" << bit << " data[bit]=" << data[bit] << endl;
          ;
          sum += two * data[bit];
        }
        sum %= 1000000007;
        two *= 2;
      }
    }
    long long int now = a[i];
    for (long long int bit = 0; bit < 61; bit++) {
      if (now & (1LL << bit)) {
        if (0) cout << "bit=" << bit << "now=" << now << endl;
        data[bit]++;
      }
    }
  }
  cout << sum << endl;
  return 0;
}
