if array is {8,7,6,7,4},result is wrong
if array is {8,7,6,7,4},result is wrong