public class Solution {
    /**
     * max increasing subsequence
     * @param arr int整型一维数组 the array
     * @return int整型
     */
    public int MLS (int[] arr) {
        // write code here
        if(arr == null || arr.length == 0){
            return 0;
        }
        int longest = 1;
        int count = 1;
        Arrays.sort(arr);
        for(int i = 1;i< arr.length;i ++){
            if(arr[i] == arr[i-1]){
                continue;
            }
            if(arr[i] - arr[i-1] == 1){
                count ++;
            }else{
                count = 1;
            }
            longest = Math.max(longest, count);
        }
        return longest;
    }
}