#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
int main() {
  int n;
  cin >> n;
  long long s[1010101];
  long long aa[1010] = {};
  long long bb[1010] = {};
  long long ma = 0;
  long long m = 0;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    long long j = 0;
    ;
    m = m > s[i] ? m : s[i];
    long long o = 1;
    while (62 >= j) {
      if (m < o) {
        bb[j]++;
        j++;
        continue;
      }
      if (s[i] & o) {
        ma += bb[j] * o;
        ma %= MOD;
        aa[j]++;
      } else {
        ma += aa[j] * o;
        ma %= MOD;
        bb[j]++;
      }
      j++;
      o *= 2;
    }
  }
  cout << ma << endl;
}
