Increasing Decreasing Sequence

My Code
My solution passes all the test cases except one (test case 0)
I have taken into account sequences like 1,2,3,4,5 and 1,1,1,1,1 and others I could think of.