import java.util.*; import java.lang.*; import java.io.*; class Main{ public static void main (String[] args) throws java.lang.Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); String[] lines = br.readLine().toString().split(" "); ArrayList list = new ArrayList(); for(String st:lines){ list.add(Integer.parseInt(st)); } Collections.sort(list); HashMap> map = new HashMap>(); for(int i=0;i next = new ArrayList(); map.put(i,next); int now = list.get(i); for(int j=i+1;j ans_map = new HashMap(); public static int calc(HashMap> map,int idx,int n){ if(ans_map.containsKey(idx)){ return ans_map.get(idx); } int max = 1; for(int i=idx;i next = map.get(i); for(int j:next){ max = Math.max(max,calc(map,j,n)+1); } } ans_map.put(idx,max); return max; } }