#t1143. 数组求和与平均

数组求和与平均

Sum and Average of an Array

Problem Description

Second lesson on arrays: iterate and accumulate at the same time.

After storing nn integers in an array, one pass over the array gives their sum; the sum divided by nn gives the average. This pattern keeps coming back in disguise: total score, average height, average temperature... the trick is always the same.

Input Format

The first line contains a positive integer nn; the second line contains nn non-negative integers separated by spaces.

Output Format

One line with two values separated by a space: the sum of the nn numbers (an integer) and the average (rounded to 2 decimal places).

Sample Input

4
1 2 3 4

Sample Output

10 2.50

Constraints

For 100% of the test data, 1≤n≤10001 \le n \le 1000, and each number does not exceed 10410^4.

Hint: store the average in a double and print it with printf("%.2f", ...) or cout << fixed << setprecision(2). Note that the largest possible sum, n×104n \times 10^4, is 10710^7, which still fits in an int.