This page is still under construction.

Parts of this page are still being built. What you see may change.

Unread Messages

Time limit1sMemory limit512 MB

Summary
Given m messages sent by members of an n-person group, report after each message the total number of unread messages across all members.
Level

Medium4 of 10

Topics
Implementation, Math, Simulation, Hash map
Solved
No attempts yet

Problem

There is a group of people in an internet email message group. Messages are sent to all members of the group, and no two messages are sent at the same time.

Immediately before a person sends a message, they read all their unread messages up to that point. Each sender also reads their own message the moment it is sent. Therefore, a person's unread messages are exactly the set of messages sent after that person's last message.

Each time a message is sent, compute the total number of unread messages over all group members.

Input

The first line of input contains two integers nn (1≤n≤1091 \le n \le 10^9) and mm (1≤m≤1,0001 \le m \le 1,000), where nn is the number of people in the group, and mm is the number of messages sent. The group members are identified by number, 11 through nn.

Each of the next mm lines contains a single integer ss (1≤s≤n1 \le s \le n), which is the sender of that message. These lines are in chronological order.

Output

Output mm lines, each with a single integer, indicating the total number of unread messages over all group members, immediately after each message is sent.

Examples2

  1. Example 1

    Input
    2 4
    1
    2
    1
    2
    
    Expected output
    1
    1
    1
    1
    
  2. Example 2

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