#include <bits/stdc++.h>
using namespace std;
long long P = 1000000007, a[500010][62], ans[500010][62], anss = 0;
int n;
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    long long x;
    int cnt = 61;
    cin >> x;
    while (x) {
      a[i][cnt] = x % 2;
      ans[i][cnt] = ans[i - 1][cnt] + a[i][cnt];
      x /= 2;
      --cnt;
    }
    for (; cnt >= 1; --cnt) ans[i][cnt] = ans[i - 1][cnt];
  }
  for (int i = 61; i >= 1; --i) {
    long long t = 1ll << (61 - i);
    for (int j = 1; j < n; ++j)
      if (a[j][i] == 1) {
        long long num = n - j - ans[n][i] + ans[j][i];
        anss += num * t;
        anss %= P;
      } else {
        long long num = ans[n][i] - ans[j][i];
        anss += num * t;
        anss %= P;
      }
  }
  cout << anss << endl;
  return 0;
}
