The Data Gap Audit
Fenwick Mill's logger is supposed to write one entry a day, but the disk fills up and days quietly go missing. Before anyone trusts a month's report the auditor asks how many days between the first and the last entry have no entry at all. Anything before the first entry or after the last is outside the audit — nobody knows whether the logger was even switched on.
Task: Print how many days are missing from the audited stretch.
Input
The first line holds an integer n, the number of entries. Each of the next n lines holds one day number. The numbers arrive in increasing order and never repeat.
Output
One line: a whole number. The first and last entries are themselves inside the stretch and count as present, so a log with no holes prints 0.
Example:
Input:
4
1
2
4
7
Output:
3
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in