A sensor logged readings that moved by a constant step: the difference between neighbouring readings was always the same (the step may be negative or zero). In transit one reading was lost, and it was neither the first nor the last. The remaining readings, in their original order, are in the array readings.
Return the lost value.
Example 1
readings=[10, 16, 19, 22] → 13
The original sequence went up by 3: 10, 13, 16, 19, 22. The value 13 was dropped.
Example 2
readings=[40, 30, 25] → 35
The step is −5: 40, 35, 30, 25. The value 35 was dropped.
Example 3
readings=[7, 7, 7] → 7
The step is zero, so the dropped value is also 7.
Constraints
3 ≤ len(readings) ≤ 1000
0 ≤ readings[i] ≤ 10⁵
readings really is a constant-step sequence with one interior element removed