n=int(input()) s=[int(input()) for i in range(n)] bool_list = [] for i in range(n -1 ): bool = ((s[i] + 1) == s[i + 1]) or ((s[i] - 1) == s[i + 1]) bool_list.append(bool) print((n-1) == bool_list.count(True))