int l = 1, r = 1;
int ans = 0;
while (r <= n) {
if (v[r] == v[r - 1]) {
ans = max(ans, r - 1);
l = r;
}
r++;
}
ans = max(ans, r - 1);
int r = 1;
int ans = 0;
for (int l = 1; l <= n; l++) {
r = max(l, r);
while (r < n && v[r + 1] != v[r])
r++;
ans = max(ans, r - l + 1);
}