n = int(input()) a = list(map(int, input().split())) z = [] if a[0] < a[1]: z.append(True) elif a[0] > a[1]: if a[1] < a[2]: z.append(False) elif a[1] > a[2]: z.append(True) for i in range(1, n - 1): if a[i - 1] < a[i] < a[i + 1]: z.append(True) elif a[i - 1] > a[i] > a[i + 1]: if z[i - 1]: z.append(False) else: z.append(True) elif a[i - 1] > a[i] < a[i + 1]: if z[i - 1]: z.append(False) else: z.append(True) elif a[i - 1] < a[i] > a[i + 1]: if z[i - 1]: z.append(True) else: if i < n - 2: if a[i + 1] < a[i + 2]: z.append(False) elif a[i + 1] > a[i + 2]: z.append(True) elif i == n - 2: z.append(True) if a[-2] < a[-1]: z.append(True) elif a[-2] > a[-1]: if z[-1]: z.append(False) else: z.append(True) ans = 0 for i in range(n): if z[i]: ans += 1 print(ans)