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. long result=0; for(long num : a){ ArrayList factors = decomposition(num); result+=calculateMove(factors); } return result; } public static ArrayList decomposition(long number){ long n=number; ArrayList factors = new ArrayList(); long a=2; while(a<=Math.pow(n,0.5)){ while(n%a==0){ factors.add(a); n=n/a; } a++; } if(n>1){ factors.add(n); } return factors; } public static long calculateMove(ArrayList factors){ Collections.reverse(factors); long move=1; long product=1; for(int i=0;i