#include <bits/stdc++.h>
using namespace std;
int main() {
  const long long MOD = 1e+9 + 7;
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  long long ans = 0, ans1 = 0;
  for (int i = 1; i < n; i++) {
    ans1 += (a[0] ^ a[i]) % MOD;
  }
  ans = ans1;
  for (int i = 0; i < n - 2; i++) {
    ans1 -= a[i];
    ans += ans1;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}
