#include <bits/stdc++.h>
const double PI = acos(-1);
using namespace std;
int main(void) {
  int N;
  cin >> N;
  long long ans = 0;
  vector<long long> A(N), suma(N), sumk(N);
  for (long long i = 0; i < (N); i++) {
    cin >> A[i];
    if (i == 0) {
      suma[i] = A[i];
      sumk[i] = (~A[i]);
    } else {
      suma[i] = suma[i - 1] + A[i];
      sumk[i] = sumk[i - 1] + (~A[i]);
    }
  }
  for (long long i = 0; i < (N - 1); i++) {
    ans += ((A[i] & (sumk[N - 1] - sumk[i])) |
            ((~A[i]) & (suma[N - 1] - suma[i])));
    ans %= 1000000007;
  }
  cout << ans << endl;
}
