#K3861. Find the Largest K

    ID: 26237 Type: Default 1000ms 256MiB

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 -3

Output: 3

The problem requires you to read input from stdin and output the result to stdout.

</p>

inputFormat

The input consists of two lines:

  1. The first line contains an integer \( n \), representing the number of elements in the array.
  2. 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.

## sample
5
3 2 -2 5 -3
3