The Missing Term
An arithmetic progression had its terms listed in order, but one interior term was deleted. Recover it.
Input: the first line has the remaining count M; the second line has the M remaining terms in order.
Output: the deleted term.
Constraints:
- 3 ≤ M ≤ 105
- the common difference is non-zero; the deleted term is not an endpoint
Sample Tests
Input 1
4 1 3 7 9
Output 1
5
Input 2
3 10 20 40
Output 2
30
Discussion (opens after you solve — no spoilers before)
No comments yet.