import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static int longestSequence(int[] a,int max) { // Return the length of the longest possible sequence of moves. int arr[]=new int[max+1]; arr[1]=arr[0]=1; arr[2]=3; // arr[3]=4; int sum=0; //System.out.println(max); for(int i=0;ifactors // System.out.println("coming at beg "+n); for(int i=0;imax) max=a[a_i]; } int result = longestSequence(a,max); System.out.println(result); in.close(); } }