Wookje's Dinner Wheel

Time limit2sMemory limit256 MB

Summary
Given a sequence where each menu number appears exactly twice, find the maximum number of values seen once but not yet seen twice at any point.
Level

Medium4 of 10

Topics
Array, Hash map, Simulation, Greedy
Solved
No attempts yet

Problem

Wookje spends time every evening deciding what to eat. He is tired of repeating the same decision, so he settles the dinner menu for NN days at once.

Wookje prepares NN distinct menus and one large wheel. He splits the wheel into NN cells of equal size and writes one menu on each cell. A cell holds exactly one menu, and a menu is written on exactly one cell.

Wookje spins the wheel by these rules.

  1. Spin the wheel and check the cell it stops on.
  2. If that cell has no sticker, put one sticker on it.
  3. If that cell already has a sticker, write the menu of that cell on the meal plan, peel the sticker off, and remove the cell. Wookje's wheel is special, so it never stops on a removed cell again.
  4. Repeat steps 1 to 3 until every cell is removed.

Under these rules, 2N2N spins settle all NN days of menus. The result of every spin is given in order. Find the largest number of stickers that were on the wheel at the same time.

Input

The first line contains the number of menus NN (1≤N≤1051 \le N \le 10^5).

The second line contains 2N2N menu numbers separated by spaces, the numbers written on the cells the wheel stopped on, in spin order. Each menu number is an integer between 11 and NN, and each number appears exactly twice.

Output

Print the largest number of stickers that were on the wheel at the same time.

Examples2

  1. Example 1

    Input
    3
    1 3 3 2 1 2
    
    Expected output
    2
    
  2. Example 2

    Input
    5
    1 1 2 2 3 3 4 4 5 5
    
    Expected output
    1