Case 2 : When N is even
else { var maxima = parseInt ( N / 2 ) ; var ans1 = 3000000000000000000 ; var R = - 1 ; for ( var i = 0 ; i < n - 1 ; ++ i ) { var diff = Math . abs ( v [ i ] - maxima ) ; if ( diff < ans1 ) { ans1 = diff ; R = v [ i ] ; } } document . write ( N + " " + R ) ; } }