Function for calculating the arithmetic mean

Swift Easy functions

Task «Function for calculating the arithmetic mean»

Write a function `average` that takes an array of integers and returns the arithmetic mean of these numbers (type Double). If the array is empty, the function should return 0.0. Input data: an integer n (number of elements), then n integers. Output the result with an accuracy of one decimal place.

Input Format

First line: an integer n (0 ≤ n ≤ 100). Second line: n integers separated by spaces.

Output Format

One number — the arithmetic mean, rounded to one decimal place.

Examples

Example 1

INPUT
4 1 2 3 4
OUTPUT
2.5

Example 2

INPUT
3 10 20 30
OUTPUT
20.0
main.swift