N = int(input()) f = input() s_f = f.split() length = [int(v) for v in s_f] i = 0 for v in range(0, N - 2): a = {length[v],length[v + 1],length[v + 2]} if len(a) == 3: if length[v] < length[v + 1] and length[v + 1] > length[v + 2]: i += 1 elif length[v] > length[v + 1] and length[v + 1]