import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { boolean[] prime; long[] moves; int isprime(long num) { int n=1000000; if(prime==null){ prime = new boolean[1000000+1]; for(int i=0;i1000000) return -1; return prime[(int)num]?1:0; } long getNextPrime(long num) { long i=num+1; while(!prime[(int)i]) i++; return i; } long getMoves(long a) { if(a==1) return 1; if(isprime(a)==1) return a+1; long moves=a; long prime=2; while(a!=1) { while(a%prime==0){ moves+=(a/2); a=a/2; } prime=getNextPrime(prime); } return moves; } long longestSequence(long[] a) { // Return the length of the longest possible sequence of moves. long totalMoves=0; for(int i=0;i