#K87967. Age Difference Between Adults and Minors
Age Difference Between Adults and Minors
Age Difference Between Adults and Minors
You are given a list of ages. Your task is to partition this list into two groups:
- Minors: those whose age is strictly less than 18.
- Adults: those whose age is at least 18.
Then, compute the difference between the sum of the ages of adults and the sum of the ages of minors. In mathematical notation, if \(A\) is the set of adults and \(M\) is the set of minors, you need to calculate:
\[ \text{result} = \sum_{a \in A} a - \sum_{m \in M} m \]If the list is empty, the result is 0.
Input Format: The input is read from standard input.
Output Format: Output the computed result to standard output.
inputFormat
The input begins with an integer \(n\) representing the number of ages. The next line contains \(n\) space-separated integers, each representing an age.
If \(n = 0\), no ages follow and the output should be 0.
outputFormat
Output a single integer which is the difference between the sum of ages of adults (ages \(\ge 18\)) and the sum of ages of minors (ages \(< 18\)).
## sample7
12 34 22 14 17 18 16
15