#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  vector<unsigned long long> v;
  vector<int> count(61, 0);
  cin >> N;
  unsigned long long sum = 0;
  unsigned long long A;
  for (int(i) = (0); (i) < (N); (i)++) {
    cin >> A;
    for (int(j) = (0); (j) < (61); (j)++) {
      sum += (((~A >> j & 1) * count[j]) << j);
      sum += (((A >> j & 1) * (i - count[j])) << j);
      sum %= 1000000007;
      count[j] += (A >> j & 1);
    }
  }
  cout << sum << endl;
  return 0;
}
