#include <bits/stdc++.h>
using namespace std;
const long long inf = 1000000007;
struct edge {
  int myc, to, c, cost;
};
struct pos {
  int to, cost, color;
};
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
vector<pair<int, int> > v[100001];
long long dp[300000][60] = {};
long long dp2[300000][60] = {};
long long a[300000];
int main() {
  int n;
  cin >> n;
  long long r = 0;
  long long ndp1[60] = {};
  long long ndp2[60] = {};
  long long s1[60];
  s1[0] = 1;
  for (int i = 0; i < 59; ++i) s1[i + 1] = s1[i] * 2;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    for (int j = 0; j < 60; ++j) {
      if ((a[i] & s1[j]) > 0) {
        ndp1[j]++;
      } else {
        ndp2[j]++;
      }
      dp[i][j] = ndp1[j];
      dp2[i][j] = ndp2[j];
    }
  }
  for (int i = 0; i < n - 1; ++i) {
    for (int j = 0; j < 60; ++j) {
      if ((a[i] & s1[j]) > 0) {
        r += s1[j] * (dp2[n - 1][j] - dp2[i][j]);
        r %= inf;
      } else {
        r += s1[j] * (dp[n - 1][j] - dp[i][j]);
        r %= inf;
      }
    }
  }
  cout << r << endl;
  return 0;
}
