if all the elements of the array are identical
if ( a [ 0 ] == a [ n - 1 ] ) return ( n * a [ 0 ] ) ; else return - 1 ; } else { let f = 0 ; for ( let i = 1 ; i < n ; i ++ ) { let p = a [ i ] - a [ 0 ] ;