#C2503. Find the Missing Number

    ID: 45827 Type: Default 1000ms 256MiB

Find the Missing Number

Find the Missing Number

You are given a sorted list of consecutive integers with exactly one missing element. Your task is to identify the missing number. The list is provided in a single line with space-separated integers.

You can compute the expected sum of all integers in the complete range using the formula: $$ S_{expected} = \frac{(first + last) \times (n+1)}{2} $$, where first is the first integer in the list, last is the last integer, and n+1 is the total count of numbers if none were missing. The missing number can then be found as the difference between the expected sum and the sum of the given integers.

inputFormat

Input is given as a single line of space-separated integers representing a sorted list of consecutive numbers with one missing element.

outputFormat

Output the missing integer.## sample

1 2 4 5
3