import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] arr = new int[n]; HashSet exist = new HashSet<>(); int left = 0; int max = 0; for (int i = 0; i < n; i++) { arr[i] = sc.nextInt(); if (exist.contains(arr[i])) { while (arr[left] != arr[i]) { exist.remove(arr[left]); left++; } left++; } else { exist.add(arr[i]); max = Math.max(max, i - left + 1); } } System.out.println(max); } }