← Back to Problems
Underwater
Easy standard Time Series
Time limit: 1 s per test  ·  Memory: 256 MB

You are given the daily values V_1 ... V_n of a portfolio. Let the running peak be P_t = max(V_1, ..., V_t).

The drawdown on day t is (P_t - V_t) / P_t. The maximum drawdown is the largest drawdown over all days.

A day t is underwater if V_t < P_t. The maximum drawdown duration is the length of the longest run of consecutive underwater days; a run that is still open on the last day counts. If no day is underwater, both answers are 0.

Input

The first line contains the integer n. Each of the next n lines contains one value V_t with at most 2 digits after the decimal point.

Output

Two numbers: the maximum drawdown (with relative error at most 1e-9) and the maximum drawdown duration in days (an integer).

Constraints

1 <= n <= 10000

0.01 <= V_t <= 10^6

Scoring

This is a standard problem: a submission scores full points if it produces the correct output for every test case, and zero otherwise.

Numeric answers are accepted if they are within a relative tolerance of 1e-09 of the expected value.

Examples

input
6
100.00
90.00
95.00
105.00
80.00
100.00
output
0.23809523809523808 2
input
3
50.00
60.00
70.00
output
0.0 0
Python 3.13 i Execution environment Isolated microVM · 1 vCPU · no internet access Time and memory limits are set per problem Available packages numpy 2.5.0scipy 1.18.0pandas 3.0.0scikit-learn 1.9.0statsmodels 0.15.0cvxpy 1.9.2