PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#CC0000007. Đoạn bài hát không trùng (Playlist)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Đoạn bài hát không trùng (Playlist)

Playlist

Source: CSES Version: Phuoc Hung OJ Extended

Problem Statement

A radio station records NN played songs in order, using an integer identifier for each song. Equal identifiers mean the same song. Find the maximum length of a contiguous segment in which no song occurs twice.

Input

The first line contains NN. The next line lists the NN song IDs in playback order.

Output

Print the maximum length of a contiguous duplicate-free segment.

Subtasks

  • Subtask 1 (20 points): 1≤N≤351\le N\le 35; 1≤ai≤1091\le a_i\le 10^9.
  • Subtask 2 (30 points): 1≤N≤25001\le N\le 2500; 1≤ai≤1091\le a_i\le 10^9.
  • Subtask 3 (50 points): 1≤N≤2⋅1051\le N\le 2\cdot 10^5; 1≤ai≤1091\le a_i\le 10^9.

Examples

Input

8
1 2 1 3 2 7 4 2

Output

5

Explanation

Positions 33 through 77 contain 1,3,2,7,41,3,2,7,4: five distinct songs.