n = int(input()) a = list(map(int, input().split())) # Calculate the maximum frequency of any value in the array from collections import defaultdict count = defaultdict(int) for num in a: count[num] += 1 max_freq = max(count.values()) if count else 0 # Calculate the maximum non-adjacent selection using dynamic programming if n == 0: max_independent = 0 elif n == 1: max_independent = 1 else: prev_not = 0 # Represents not taking the previous element prev_yes = 1 # Represents taking the previous element for i in range(1, n): current_not = max(prev_not, prev_yes) current_yes = prev_not + 1 prev_not, prev_yes = current_not, current_yes max_independent = max(prev_not, prev_yes) # The answer is the maximum of the two strategies print(max(max_freq, max_independent))