Returns true if a permutation of arr [ 0. . n - 1 ] can form arithmetic progression
function checkIsAP ( arr , n ) { var hm = new Map ( ) ; var smallest = 1000000000 , second_smallest = 1000000000 ; for ( var i = 0 ; i < n ; i ++ ) {