P23627 [AtCoder] Average of Differences
普及-
题目描述

Problem Description

For a sequence of positive integers $ a_n $ with $ n $ elements, find the average of the differences between adjacent terms, i.e., the average value of $ a_{i+1} - a_{i} $ ($1 \leq i \leq n - 1$).

Input Format

The input is given in the following format:

$ n $ $ a_1 $ $ a_2 $ $ a_3 $ $ ... $ $ a_n $

  • The first line contains an integer $ n $ ($2 \leq n \leq 100$), representing the number of elements in the sequence.
  • The second line contains the terms of the sequence $ a_i $ ($1 \leq a_i \leq 1{,}000{,}000{,}000$).

Output Format

Output the average value of the differences between adjacent terms in one line.

The answer will be considered correct if the absolute error is within $ 0.001 $.

Ensure there is a newline at the end, and do not include any extra characters or blank lines.

Sample Input and Output

Sample Input #1

4
4 3 2 1

Sample Output #1

-1

Sample Input #2

4
1 2 3 5

Sample Output #2

1.333

Sample Input #3

4
1000000000 1000000000 1000000000 1000000000

Sample Output #3

0

Sample Input #4

4
1000000000 324219581 581395481 2319

Sample Output #4

-333332560.333333313

Notes/Hints

Sample Explanation 1

The average of the differences between adjacent terms is $ ((3 - 4) + (2 - 3) + (1 - 2)) / 3 $.

Sample Explanation 2

The average of the differences between adjacent terms is $ (1 + 1 + 2) / 3 $.

Sample Explanation 4

Ensure the output has an absolute error within $ 0.001 $.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
4 4 3 2 1
样例输出
-1