for (int i = 1; i <= n; ++i) {
cin >> x;
for (auto key : g[x]) {
int to = (key^x);
ans[to] = 1;
while (r[to] > x) {
r[to]--;
if (r[to] != x) g[r[to]].push_back(to);
}
}
g[x] = {};
}