find the second max value in an array with the complexity of n + log(n) - 2