import java.util.*;


public class Solution {
    /**
     *
     * @param arr int整型一维数组 the array
     * @return int整型
     */
    public static int maxLength (int[] arr) {
        // write code here
        int maxLength = 0;
        LinkedList<Integer> list = new LinkedList<>();
        for(int i = 0 ; i < arr.length ; i++){
            while (list.contains(arr[i])){
                list.removeFirst();
            }
            list.add(arr[i]);
            if (list.size() > maxLength){
                maxLength = list.size();
            }
        }
        return maxLength;
    }

    public static void main(String[] args) {
        int[] arr = {2,2,3,4,3};
        System.out.println(maxLength(arr));
    }
}