#include <bits/stdc++.h>
using namespace std;
long long arr[300005];
bool check(long long mask, long long pos) { return mask & (1LL << pos); };
int cnt[65];
int main() {
  int n;
  cin >> n;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 60; j++) {
      if (check(arr[i], j)) {
        sum += (1LL * (i - cnt[j]) * (1LL << j) % 1000000007) % 1000000007;
      } else {
        sum += (1LL * cnt[j] * (1LL << j) % 1000000007) % 1000000007;
      }
      sum %= 1000000007;
      if (check(arr[i], j)) cnt[j]++;
    }
  }
  cout << sum << endl;
  return 0;
}
