Problem list
Log in
#coci00049 · COCI 2007/2008 Contest 3

Cetiri

Bronze III 1.0 s 32 MB

Mirko has chosen four integers which form an arithmetic progression. In other words, when the four numbers are sorted, then the difference between each pair of adjacent elements is constant.

As has become usual, Mirko lost one of the numbers and also is not sure whether the remaining three are in the correct (sorted) order.

Write a program that, given the three remaining numbers, finds the fourth number.

Input

The input contains $3$ integers between $-100$ and $100$ on a single line, separated by single spaces.

Note: the input data will guarantee that a solution, although not necessarily unique, will always exist.

Output

Output any number which could have been the fourth number in the sequence.

Example 1

Input
4 6 8
Output
10

Example 2

Input
10 1 4
Output
7
Source
COCI 2007/2008 Contest 3
Appears in
Not part of a ladder, contest or set yet.
Accepted 3 Submissions 5 Acceptance 100% Solvers 3

Discussion

Threads about this problem. Spoilers are collapsed; wrap hints in ||double bars||.

No discussion yet. Start a thread if something here needs explaining.

Recent submissions Open with filters
Code