#K63722. Calculate Power Value of an Array
Calculate Power Value of an Array
Calculate Power Value of an Array
You are given an array of integers. Your task is to compute the power value of the array. The power value is calculated by first summing the digits of each array element, then summing these results to get an intermediate value, and finally repeatedly summing the digits of this intermediate value until a single-digit number is obtained.
In mathematical terms, given an integer \( n \), its digit sum is defined as:
\( \text{digit\_sum}(n) = \sum_{d \in \text{digits of } n} d \)
You need to implement a program which reads the input from standard input (stdin) and writes the output to standard output (stdout).
inputFormat
The input is given via standard input. The first line contains an integer ( n ) representing the number of elements in the array. The second line contains ( n ) space-separated integers that constitute the array.
outputFormat
Output a single integer, which is the power value of the array.## sample
3
987 123 456
9