import sys input=lambda: sys.stdin.readline().rstrip() n=int(input()) A=[int(i) for i in input().split()] ans=0 for i in range(1,n-1): a,b,c=A[i-1:i+2] if a!=b and b!=c and c!=a: if b