#include <bits/stdc++.h>
using namespace std;
long long v[64], g[300001], n, sum, ans;
int main() {
  cin >> n;
  for (int i = 0; i < n; i += 1) {
    cin >> g[i];
    sum += g[i];
    sum %= 1000000007;
    long long a = g[i], cnt = 0;
    while (a > 0) {
      if (a % 2 == 1) {
        v[cnt] += 1;
      }
      a /= 2;
      cnt += 1;
    }
  }
  for (int i = 0; i < n; i += 1) {
    long long a = g[i], cnt = 0;
    ans += sum + (n - i - 2) * g[i];
    ans %= 1000000007;
    while (a > 0) {
      if (a % 2 == 1) {
        ans -= (v[cnt] - 1) * (1ll << cnt) * 2ll;
        ans %= 1000000007;
        ans += 1000000007;
        ans %= 1000000007;
        v[cnt] -= 1;
      }
      a /= 2;
      cnt += 1;
    }
    sum -= g[i];
    sum %= 1000000007;
    sum += 1000000007;
    sum %= 1000000007;
  }
  cout << ans << endl;
}
