#K42602. Thickest Book Removal

    ID: 27124 Type: Default 1000ms 256MiB

Thickest Book Removal

Thickest Book Removal

You are given an integer (n) representing the number of books and a list of (n) integers representing the thickness of each book. Your task is to determine the thickness of the thickest book that can be removed such that its thickness is strictly greater than the average thickness of all books. In other words, if (T) is the total thickness and (a = \frac{T}{n}) is the average, you need to choose a book with thickness (t) satisfying (t > a) and output the maximum such (t). If no book satisfies this condition, output (-1).

Note: The input will be provided via standard input and the output should be printed to standard output.

inputFormat

The first line contains a single integer (n) representing the number of books. The second line contains (n) space-separated integers where the (i^{th}) integer denotes the thickness of the (i^{th}) book.

outputFormat

Print a single integer — the thickness of the thickest book that can be removed so that its thickness is strictly greater than the average thickness of all books. If no such book exists, print (-1).## sample

5
4 2 3 6 5
6

</p>