#include <bits/stdc++.h>
using namespace std;
const int N = 350000;
long long n, data[N];
struct node {
  long long data, num;
} f[N], f1[N];
const long long MOD = 1000000007;
bool cmp(node &a, node &b) {
  if (a.data == b.data)
    return a.num < b.num;
  else
    return a.data < b.data;
}
int td[N];
int main() {
  scanf("%lld", &n);
  for (int i = 1; i <= n; i++)
    scanf("%lld", &f[i].data), f[i].data %= MOD,
        f[i].num = i, td[i] = -1, f1[i].data = f[i].data, f1[i].num = i;
  ;
  sort(f1 + 1, f1 + 1 + n, cmp);
  for (int i = 1; i < n; i++)
    if (f1[i].data == f1[i + 1].data) td[f1[i].num] = f1[i + 1].num;
  long long m, ans = 0, now = 0;
  for (int i = n - 1; i > 0; i--) {
    m = n;
    if (td[i] != -1) m = td[i], ans += data[td[i]], data[i] += data[td[i]];
    for (int j = i + 1; j <= m; j++)
      data[i] += f[i].data ^ f[j].data, ans += f[i].data ^ f[j].data,
          data[i] %= MOD, ans %= MOD;
  }
  cout << ans;
}
