In the Monotonic Question the algorithm wont work for one case

Like the algorithm i believe is for right for most cases but in a case like 1 2 2 2 2 ,it would confirm that it’s a monotonic array but it isn’t. Or is it?