#include #include #include #include using namespace std; int main() { int N; cin >> N; int* buffer = new int[N]; for (int i = 0; i < N; i++) { string A; cin >> A; buffer[i] = stoi(A); } unordered_map foundNumbers; int maxCount = 0; int j = 0; for (int i = 0; i < N; i++) { int num = buffer[i]; if (foundNumbers.count(num) == 0) { foundNumbers[num] = 0; } else { maxCount = max(maxCount, i - j); while (true) { foundNumbers.erase(buffer[j]); if (buffer[j] == buffer[i]) break; j++; } foundNumbers[num] = 0; j++; } } maxCount = max(maxCount, (int)foundNumbers.size()); cout << maxCount << endl; return 0; }