import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static long longestSequence(List a) { // Return the length of the longest possible sequence of moves. long total = 0; for(int i=0; i a = new ArrayList(); for(int a_i = 0; a_i < n; a_i++){ a.add(in.nextLong()); } long result = longestSequence(a); System.out.println(result); in.close(); } }