Search And Rescue
/
No tags
Problem
Editorial
Analytics

An Arithmetic Progression is defined as one in which there is a constant difference between the consecutive terms of a given series of numbers. You are provided with consecutive elements of an Arithmetic Progression. There is however one hitch: exactly one number from the original series is missing from the set of numbers which have been given to you. The rest of the given series is the same as the original AP. Find the missing number.

PS:

• First and last terms of the AP are included in the series.
• Only the element in the middle is missing.
• In case of 0 as the constant difference for the AP, answer will be the same constant number of the AP.

• Input:
The first line contains an Integer N, which is the number of terms which will be provided as input. This is followed by N consecutive Integers, with a space between each pair of integers. All of these are on one line, and they are in AP (other than the point where an integer is missing).
Output:
One Number which is the missing integer from the series.

SAMPLE INPUT
5
1 3 5 9 11
SAMPLE OUTPUT
7
Explanation

You are provided with 5 integers. As you can can observe, they have been picked from a series, in which the starting term is 1 and the common difference is 2. The only aberration, i.e. the missing term (7), occurs between 5 and 9. This is the missing element which you need to find.

Time Limit: 5.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB

## This Problem was Asked in

Initializing Code Editor...