import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static long longestSequence(long[] a) { // Return the length of the longest possible sequence of moves. ArrayList al = new ArrayList(); long sum=0,temp=0,box=0,box1=0,temp1=0; int si=0; int n= a.length; Arrays.sort(a); for(int i=0 ; i0){ a[i]=box1; if(a[i]!=1){ while(((a[i])&(a[i]-1))!=0){ a[i]=a[i]-1; }} al.add(a[i]); box1=box1-a[i]; } si=al.size(); for(int j=0; j