using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution { static long longestSequence(long[] a) { long moves = 0; for (int i = 0; i < a.Length; i++) { if(a[i] == 1) { moves += a[i]; } else if (a[i] % 2 == 0) { moves += a[i]; while (a[i] != 1) { var temp = a[i] / 2; moves += temp; a[i] = temp; } } else { long lpf = checkForPrimeAndPrimeFactor(a[i]); if (lpf == 0) { moves += (a[i] + 1); } else { while (a[i] != 1) { moves += a[i]; var temp = a[i] / lpf; moves += temp; a[i] = temp; } } } } return moves; } static long checkForPrimeAndPrimeFactor(long length) { for(int i=3;i