Closest to Zero
Print the value closest to zero. If a negative and a positive value tie in distance, print the positive one.
Input: the first line has an integer N; the second line has N integers separated by spaces.
Output: the value closest to zero (positive wins ties).
Constraints:
- 1 ≤ N ≤ 2000
- −109 ≤ ai ≤ 109
Sample Tests
Input 1
5 7 -2 3 2 -5
Output 1
2
Input 2
2 -3 3
Output 2
3
Discussion (opens after you solve — no spoilers before)
No comments yet.