import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static long lowestPrimeFactor(long n) { for (int i=2; i< (int) Math.sqrt(n) + 1; i++) { if ((n / (double) i) % 1 == 0) { return i; } } return n; } static long longestSequence(long[] a) { long sum = 0; for (long n : a) { // For each stick long n1 = n; ArrayList factors = new ArrayList(); while (n > 1) { // Fill list with factors long factor = lowestPrimeFactor(n); factors.add(factor); n /= factor; } for (int i=0; i