import java.util.*; public class Optimal{ static int size = Integer.MAX_VALUE; static long gcd(long a, long b){ if(b==0){ return a; } return gcd(b, (a%b)); } public static void main(String[] args) throws java.lang.Exception{ Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0){ long n = sc.nextLong(); long sum = 0; long a[] = new long [(int)n+1]; for(long i=0; i=0; i--){ suf[(int)i] =gcd(suf[(int)i+1],a[(int)i]); } h[0] = suf[1]; h[(int)n-1] = pre[(int)n-2]; for(long i=1;i