#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); } int maxCount = 0; int count = 0; unordered_map foundNumbers; for (int index = 0; index < N; index++) { int num = buffer[index]; if (foundNumbers.find(num) == foundNumbers.end()) { foundNumbers[num] = index; count++; } else { if (maxCount < count) maxCount = count; int matchedNumIndex = foundNumbers[num]; count = index - matchedNumIndex; foundNumbers[num] = index; for (int i = 0; i < matchedNumIndex; i++) { foundNumbers.erase(buffer[i]); } } } if (maxCount < count) maxCount = count; cout << maxCount << endl; return 0; }