An integer sequence x0,x1,…,xN−1 is convex when xi−1+xi+1≥2xi holds for every i with 1≤i≤N−2. A sequence of length 1 or 2 is always convex.
For example, 7, 3, 4, 5, 7 and 4, 2, 1, 3 are convex, while 4, 3, 1, 2 and 5, 7, 3 are not.
You are given a sequence A=a0,a1,…,aN−1. One operation picks an index i and replaces ai with ai−1, and no other operation is allowed. You may pick the same index several times, and an element may become negative. Write a program that finds the minimum number of operations that makes A convex.