All problems

Problem 781

Average of an Array

Easy · 10 pts · Array, Basics

Problem

Print the average of N non-negative integers, rounded down to a whole number. The average is the sum of the values divided by how many there are. Add all the values in a 64-bit variable (the sum can exceed 2^31), then use integer division by N, which rounds down for non-negative numbers.

Input

The first line contains an integer N, the size of the array. The second line contains N space-separated integers A[0], A[1], ..., A[N-1].

Output

Print the average, rounded down.

Constraints

1 <= N <= 100000; 0 <= A[i] <= 10^9

Example input

3
4 7 8

Example output

6

Explanation

For 4 7 8 the sum is 19 and there are 3 values, so the average is 19 / 3 = 6.33..., which rounds down to 6.

Every problem here can be used in a RelayTrixCode team match. Create a room.

Previous: Sum of Squares up to N Next: Count Even and Odd Elements