//
// Playlist
//
//
// Created by Krish Narsaria on 05/01/25.
//
#include <bits/stdc++.h>
using namespace std;
#define ll long long
void solve() {
unordered_map<int, int> lastIndex;
int n, a, ans = 0, start = 0;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a;
if (lastIndex.find(a) != lastIndex.end() && lastIndex[a] >= start) {
start = lastIndex[a] + 1;
}
lastIndex[a] = i;
ans = max(ans, i - start + 1);
}
cout << ans << "\n";
}
int main(){solve();}
Ly8KLy8gIFBsYXlsaXN0Ci8vICAKLy8KLy8gIENyZWF0ZWQgYnkgS3Jpc2ggTmFyc2FyaWEgb24gMDUvMDEvMjUuCi8vCiAKI2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgbGwgbG9uZyBsb25nCnZvaWQgc29sdmUoKSB7CiAgICB1bm9yZGVyZWRfbWFwPGludCwgaW50PiBsYXN0SW5kZXg7CiAgICBpbnQgbiwgYSwgYW5zID0gMCwgc3RhcnQgPSAwOwogICAgY2luID4+IG47CiAgICBmb3IgKGludCBpID0gMDsgaSA8IG47IGkrKykgewogICAgICAgIGNpbiA+PiBhOwogICAgICAgIGlmIChsYXN0SW5kZXguZmluZChhKSAhPSBsYXN0SW5kZXguZW5kKCkgJiYgbGFzdEluZGV4W2FdID49IHN0YXJ0KSB7CiAgICAgICAgICAgIHN0YXJ0ID0gbGFzdEluZGV4W2FdICsgMTsKICAgICAgICB9CiAgICAgICAgbGFzdEluZGV4W2FdID0gaTsKICAgICAgICBhbnMgPSBtYXgoYW5zLCBpIC0gc3RhcnQgKyAxKTsKICAgIH0KICAgIGNvdXQgPDwgYW5zIDw8ICJcbiI7Cn0KaW50IG1haW4oKXtzb2x2ZSgpO30=