Polycarp plans to conduct a load testing of its new project Fakebook. He already agreed with his friends that at certain points in time they will send requests to Fakebook. The load testing will last n minutes and in the i-th minute friends will send a_{i} requests.

Polycarp plans to test Fakebook under a special kind of load. In case the information about Fakebook gets into the mass media, Polycarp hopes for a monotone increase of the load, followed by a monotone decrease of the interest to the service. Polycarp wants to test this form of load.

Your task is to determine how many requests Polycarp must add so that before some moment the load on the server strictly increases and after that moment strictly decreases. Both the increasing part and the decreasing part can be empty (i. e. absent). The decrease should immediately follow the increase. In particular, the load with two equal neigbouring values is unacceptable.

For example, if the load is described with one of the arrays [1, 2, 8, 4, 3], [1, 3, 5] or [10], then such load satisfies Polycarp (in each of the cases there is an increasing part, immediately followed with a decreasing part). If the load is described with one of the arrays [1, 2, 2, 1], [2, 1, 2] or [10, 10], then such load does not satisfy Polycarp.

Help Polycarp to make the minimum number of additional requests, so that the resulting load satisfies Polycarp. He can make any number of additional requests at any minute from 1 to n.


-----Input-----

The first line contains a single integer n (1 ≤ n ≤ 100 000) — the duration of the load testing.

The second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 10^9), where a_{i} is the number of requests from friends in the i-th minute of the load testing.


-----Output-----

Print the minimum number of additional requests from Polycarp that would make the load strictly increasing in the beginning and then strictly decreasing afterwards.


-----Examples-----
Input
5
1 4 3 2 5

Output
6

Input
5
1 2 2 2 1

Output
1

Input
7
10 20 40 50 70 90 30

Output
0



-----Note-----

In the first example Polycarp must make two additional requests in the third minute and four additional requests in the fourth minute. So the resulting load will look like: [1, 4, 5, 6, 5]. In total, Polycarp will make 6 additional requests.

In the second example it is enough to make one additional request in the third minute, so the answer is 1.

In the third example the load already satisfies all conditions described in the statement, so the answer is 0.

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = 'n = int(input())\na = list(map(int,input().strip().split()))\nif n > 1:\n\tli = [0]*n\n\tri = [0]*n\n\tlm = a[0]\n\tc = [0]*n\n\tb = [0]*n\n\tb[0] = a[0]\n\tfor i in range(1,n):\n\t\tif lm >= a[i]:\n\t\t\tli[i] = li[i-1] + (lm+1-a[i])\n\t\t\tlm = lm+1\n\t\telse:\n\t\t\tli[i] = li[i-1]\n\t\t\tlm = a[i]\n\t\tb[i] = lm\n\tlm = a[n-1]\n\tc[n-1] = a[n-1]\n\tfor i in range(n-2,-1,-1):\n\t\tif lm >= a[i]:\n\t\t\tri[i] = ri[i+1] + (lm+1-a[i])\n\t\t\tlm = lm+1\n\t\telse:\n\t\t\tri[i] = ri[i+1]\n\t\t\tlm = a[i]\n\t\tc[i] = lm\n\tans = 1<<64\n\tfor i in range(n):\n\t\tif i == 0:\n\t\t\tans = min(ans,ri[i],ri[i+1])\n\t\telif i== n-1:\n\t\t\tans = min(ans,li[i],li[i-1])\n\t\telse:\n\t\t\tv1 = li[i] + ri[i+1]\n\t\t\tif b[i] == c[i+1]:\n\t\t\t\tv1 += 1\n\t\t\tv2 = ri[i] + li[i-1]\n\t\t\tif c[i] == b[i-1]:\n\t\t\t\tv2 +=1\n\t\t\tval = min(v1,v2)\n\t\t\tans = min(ans,val)\n\tprint(ans)\nelse:\n\tprint(0)\n'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 13885