import sys from collections import defaultdict def main(): n = int(sys.stdin.readline()) a = list(map(int, sys.stdin.readline().split())) # Calculate maximum frequency of any number freq = defaultdict(int) for num in a: freq[num] += 1 max_freq = max(freq.values()) if freq else 0 # Calculate maximum non-adjacent count using dynamic programming if n == 0: max_non_adjacent = 0 else: prev_no = 0 # previous state: not taking the previous element prev_yes = 1 # previous state: taking the previous element for i in range(1, n): current_no = max(prev_no, prev_yes) current_yes = prev_no + 1 prev_no, prev_yes = current_no, current_yes max_non_adjacent = max(prev_no, prev_yes) # The answer is the maximum of the two values print(max(max_freq, max_non_adjacent)) if __name__ == "__main__": main()