HZNUOJ

The nearest taller cow

Tags:
Time Limit:  3 s      Memory Limit:   64 MB
Submission:220     AC:32     Score:98.06

Description

Farmer Zhao's N cows (1 ≤ N ≤ 1,000,000) are lined up in a row. So each cow can see the nearest cow which is taller than it. You task is simple, given the height (0 < height ≤ 109) of each cow lined up in the row, to calculate the distance between each cow and its nearest taller cow (the nearest cow which is taller than him), if it is the tallest cow in the row, such distance is regarded as n. You should output the average distance.

Input

For each test case:

Line 1: One integers, N

Lines 2: N integers. The i-th integer is the height of the ith cow in the row.

Output

The average distance to their nearest taller cow, rounded up to 2 decimals.

Samples

input
7 7 6 5 8 6 4 10
output
2.43

Hint

You may suffer a precision problem. To ensure that you can output a correct answer on OJ(Online Judge), please write your output statements like it:
#define eps 1e-7
......
printf("%.2f\n",sum/n+eps);
——noted by CYP

Source

湖南大学2009校赛