N=int(input()) A=list(map(int,input().split())) P=0 Q=0 for i in range(1,N): if A[i-1]==A[i]: P+=1 else: P=0 Q+=P print(Q)