import java.util.*;
public class Solution {
public int solution(int[] nums){
int answer = 0;
//set으로 중복된 원소 제거
HashSet<Integer> set = new HashSet<>();
for(int i:nums) set.add(i);
//set을 돌면서 하나 작은거 있는지 찾고 없으면 그다음숫자 있는지 확인
for(int i : set){
if(set.contains(i-1)) continue;
int cnt = 0;
while(set.contains(i)){
cnt++;
i++;
}
answer = Math.max(answer, cnt);
}
return answer;
}
public static void main(String[] args){
Solution T = new Solution();
System.out.println(T.solution(new int[]{8, 1, 9, 3, 10, 2, 4, 0, 2, 3}));
System.out.println(T.solution(new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0}));
System.out.println(T.solution(new int[]{3, 3, 3, 3, 3, 3, 3, 3}));
System.out.println(T.solution(new int[]{-3, -1, -2, 0, 3, 3, 5, 6, 2, 2, 1, 1}));
System.out.println(T.solution(new int[]{-5, -3, -1, -4, 3, 3, 5, 6, 2, 2, 1, 1, 7}));
}
}