시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 351 148 111 41.887%

문제

오늘은 애플의 아이폰 9S가 출시되는 날이다. N(1 ≤ N ≤ 1000)명의 사람들은 새 아이폰을 누구보다 먼저 구매하기 위해서 애플 스토어 앞에 한 줄로 서있다. 아이폰 9S는 구매자가 용량을 마음대로 정할 수 있다. 즉, 지금까지 아이폰은 16/32/64GB와 같이 용량의 크기가 미리 정해져 있었다. 하지만, 9S는 자신이 원하는 용량의 크기 B(i)를 점원에게 말하면, 정확하게 그 용량을 가진 아이폰 9S를 그 자리에서 만들어 구매하는 방식이다.

애플 스토어의 점원 상근이는 같은 용량을 원하는 사람들이 연속되어있면, 더 보기 좋을 것이라고 생각한다. 따라서, 특정 용량을 정해서, 그 용량을 원하는 사람을 줄에서 모두 빼버리려고 한다.

어떤 용량을 원하는 사람을 줄에서 빼 버리면, 같은 용량을 원하는 사람들이 연속되어 있는 구간의 길이중 가장 긴 값이 최대가 되는지 구하는 프로그램을 작성하시오.

입력

첫째 줄에 N이 주어진다. 둘째 줄부터 N개 줄에는 줄을 서 있는 순서대로 각 사람이 원하는 용량 B(i)가 주어진다. B(i)는 0보다 크거나 같고, 1,000,000보다 작거나 같은 정수이다.

출력

상근이가 만들 수 있는 가장 길이가 긴 같은 용량을 원하는 사람의 연속 구간의 길이를 출력한다.

예제 입력 1

9
2
7
3
7
7
3
7
5
7

예제 출력 1

4

힌트

사람 9명이 줄을 서있고 각 사람이 원하는 용량의 크기는 2, 7, 3, 7, 7, 3, 7, 5, 7 이다.

용량 3을 원하는 사람을 줄에서 빼버리면, 줄은 2, 7, 7, 7, 7, 5, 7가 되고, 7을 원하는 사람이 4명이 연속된 구간이 가장 길이가 긴 구간이다.

W3sicHJvYmxlbV9pZCI6IjU4ODMiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWM1NDRcdWM3NzRcdWQzZjAgOVMiLCJkZXNjcmlwdGlvbiI6IlxyXG48cD5cdWM2M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