To store the maximum element from the original array
int maxEle = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { gcd = __gcd ( gcd , arr [ i ] ) ; maxEle = max ( maxEle , arr [ i ] ) ; } int totalMoves = ( maxEle / gcd ) - n ;