#include <bits/stdc++.h>
using namespace std;
int main() {
  long long A = (long long)pow(2, 59), ans = 0;
  int n, a;
  cin >> n;
  long long D[300005];
  for (int i = 0; i < (n); ++i) cin >> D[i];
  for (int i = 0; i < (60); ++i) {
    a = 0;
    for (int j = 0; j < (n); ++j) {
      if (D[j] >= A) {
        a++;
        D[j] -= A;
      }
    }
    ans = (ans + (((long long)pow(2, 59 - i) % 1000000007) * a * (n - a)) %
                     1000000007) %
          1000000007;
    A /= 2;
  }
  cout << ans << endl;
}
