Average of N

Lab C++ Beginner 10 points

Read n and then n integers. Print the average with 2 decimals.

Input

n, then n integers.

Output

One line.

Example

Input

4
10 20 30 41

Output

25.25
Sample input available Sample output available
Editor
C++

Hints

Read a count first so you know exactly how many numbers follow.

Solution explanation

Reading an exact count is important here: the browser never signals the end of the input.

Show solution
#include <iostream>
#include <iomanip>
using namespace std;

int main() {
    int n;
    cin >> n;
    long long sum = 0;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        sum += x;
    }
    cout << fixed << setprecision(2) << static_cast<double>(sum) / n << "\n";
    return 0;
}
Output
Answer
HOME LEARN COMMUNITY DASHBOARD