#include <bits/stdc++.h>
using namespace std;
long long M = 1000000000 + 7;
long long sum[200005][65];
long long pot[63];
int main() {
  pot[0] = 1LL;
  for (int i = 1; i < 62; i++) {
    pot[i] = (pot[i - 1] * 2LL) % M;
  }
  int n;
  cin >> n;
  vector<long long> arr;
  long long temp;
  for (int i = 0; i < n; i++) {
    cin >> temp;
    arr.push_back(temp);
  }
  for (int i = 0; i < n; i++) {
    vector<int> many;
    for (int x = 0; x < 61; x++) {
      if (((1LL << x) & arr[i]) == (1LL << x)) {
        many.push_back(1LL);
      } else {
        many.push_back(0);
      }
    }
    for (int x = 0; x < 61; x++) {
      if (i != 0) {
        sum[i][x] = sum[i - 1][x] + many[x];
      } else {
        sum[i][x] = many[x];
      }
    }
  }
  long long ans = 0;
  for (int i = 1; i < n; i++) {
    for (int x = 0; x < 61; x++) {
      if (((1LL << x) & arr[i]) == (1LL << x)) {
        long long times = (1LL * i) - sum[i - 1][x];
        long long add = (times * pot[x]) % M;
        ans = (ans + add) % M;
      } else {
        long long times = sum[i - 1][x];
        long long add = (times * pot[x]) % M;
        ans = (ans + add) % M;
      }
    }
  }
  cout << ans << '\n';
  return 0;
}
