#K3861. Find the Largest K
Find the Largest K
Find the Largest K
You are given an array of integers. Your task is to find the largest integer \( k \) such that both \( k \) and \( -k \) appear in the array. If no such integer exists, output 0.
Example:
Input: 5 3 2 -2 5 -3Output: 3
The problem requires you to read input from stdin
and output the result to stdout
.
inputFormat
The input consists of two lines:
- The first line contains an integer \( n \), representing the number of elements in the array.
- The second line contains \( n \) space-separated integers.
outputFormat
Output a single integer, the largest integer \( k \) for which both \( k \) and \( -k \) appear in the array. If no such integer exists, output 0.
## sample5
3 2 -2 5 -3
3