#K43817. Find Inactive User ID

    ID: 27394 Type: Default 1000ms 256MiB

Find Inactive User ID

Find Inactive User ID

You are given a total number of users, N, where each user is assigned a unique ID from 1 to N. However, one user is inactive, and its ID is missing from the active IDs list. Your task is to find the missing user ID.

The sum of the first N natural numbers can be calculated using the formula:

N×(N+1)2\frac{N \times (N+1)}{2}

By subtracting the sum of the active user IDs from the total sum, you can determine the inactive user ID.

Example 1:

Input:
6
1 2 4 3 6

Output: 5

</p>

Example 2:

Input:
3
3 1

Output: 2

</p>

Constraints:

  • 2 ≤ N ≤ 104
  • 1 ≤ userIDs[i] ≤ 104 for each active user ID
  • The active user IDs list has exactly N-1 integers

Your solution should have a time complexity of O(N) and use O(1) auxiliary space.

inputFormat

The input is read from stdin and consists of two lines:

  • The first line contains an integer N, the total number of users.
  • The second line contains N-1 space-separated integers representing the active user IDs.

outputFormat

Print to stdout a single integer which is the missing (inactive) user ID.

## sample
6
1 2 4 3 6
5

</p>