Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/eng-past-qoldiq

Lowest balance

Medium 1000 ms 64 MB 47%
Share

An account initially holds $0$ soums. $n$ operations were performed one after another: a positive number means money came into the account, a negative number means money was withdrawn (the balance may also become negative, which is a debt). Among the balances after each operation, find the lowest one and the number of the operation after which it occurred. The initial $0$ also counts (its operation number is $0$). If the lowest balance occurs several times, take the first one.

The balance after each operation as a polyline; the lowest point is highlighted

Input

The first line contains a positive integer $n$.
The second line contains $n$ integers — the operations.

Output

Two integers separated by a space: the lowest balance and the operation number.

Note

$1 \le n \le 10^{5}$
each operation is from $-10^{9}$ to $10^{9}$

Examples

Input #1
6
500 -700 300 -400 -200 1000
Output #1
-500 5
Input #2
3
100 200 -50
Output #2
0 0

Sign in to submit a solution

Signing up is free and takes a minute.