#K55362. Even Redistribution of Books

    ID: 29959 Type: Default 1000ms 256MiB

Even Redistribution of Books

Even Redistribution of Books

You are given n shelves and a list of n non-negative integers where each integer represents the number of books on a shelf. Your task is to determine whether it is possible to redistribute all the books so that every shelf ends up with the same number of books.

Mathematically, let \(a_i\) represent the number of books on shelf \(i\) for \(1 \leq i \leq n\). The total number of books is \(S = \sum_{i=1}^{n} a_i\). It is possible to redistribute the books evenly if and only if \(S \bmod n = 0\).

inputFormat

The input is given via standard input. The first line contains an integer (n) representing the number of shelves. The second line contains (n) space-separated integers which indicate the number of books on each shelf.

outputFormat

Print "YES" if it is possible to redistribute the books evenly across all shelves, otherwise print "NO".## sample

4
3 3 3 3
YES