n = int(input()) a = list(map(int, input().split())) st = [] for x in a: st.append(x) if len(st) >= 3 and st[-3] == st[-2] == st[-1]: for _ in range(3): st.pop() print(n - len(st))