In this exercise, you have to analyze records of temperature to find the closest to zero.
Write a program that prints the temperature closest to 0 among input data.
Input
- N, the number of temperatures to analyse (optional). This will be nonzero.
- The N temperatures expressed as integers ranging from -273 to 5526.
Output
Output the temperature closest to 0. If two temperatures are equally close, take the positive one. For instance, if the temperatures are -5 and 5, output 5.
Example
Input
5
1 -2 -8 4 5
Output
1
This challenge is similar to this one on CodinGame, you can view the problem statement source here. Some modifications have been made to the text.