N = int(input()) A= list(map(int, input().split())) z = [0]*N pre=10**6 skip = False renzoku=False for i in range(N): if not renzoku: if A[i]==pre: renzoku=True if i>1: z[i-2]=0 z[i]=1 z[i-1]=1 skip=True else: if skip: skip=False else: z[i]=1 skip=True else: if A[i]!=pre: skip=False renzoku=False else: z[i]=1 pre=A[i] print(sum(z))