Function to find the gcd of a path
static int find_gcd ( Vector < Integer > arr ) { if ( arr . size ( ) == 1 ) return arr . get ( 0 ) ; int g = arr . get ( 0 ) ; for ( int i = 1 ; i < arr . size ( ) ; i ++ ) { g = gcd ( g , arr . get ( 1 ) ) ; } return g ; }