The life goes up and down, just like nice sequences. Sequence t_1, t_2, ..., t_{n} is called nice if the following two conditions are satisfied:   t_{i} < t_{i} + 1 for each odd i < n;  t_{i} > t_{i} + 1 for each even i < n. 

For example, sequences (2, 8), (1, 5, 1) and (2, 5, 1, 100, 99, 120) are nice, while (1, 1), (1, 2, 3) and (2, 5, 3, 2) are not.

Bear Limak has a sequence of positive integers t_1, t_2, ..., t_{n}. This sequence is not nice now and Limak wants to fix it by a single swap. He is going to choose two indices i < j and swap elements t_{i} and t_{j} in order to get a nice sequence. Count the number of ways to do so. Two ways are considered different if indices of elements chosen for a swap are different.


-----Input-----

The first line of the input contains one integer n (2 ≤ n ≤ 150 000) — the length of the sequence.

The second line contains n integers t_1, t_2, ..., t_{n} (1 ≤ t_{i} ≤ 150 000) — the initial sequence. It's guaranteed that the given sequence is not nice.


-----Output-----

Print the number of ways to swap two elements exactly once in order to get a nice sequence.


-----Examples-----
Input
5
2 8 4 7 7

Output
2

Input
4
200 150 100 50

Output
1

Input
10
3 2 1 4 1 4 1 4 1 4

Output
8

Input
9
1 2 3 4 5 6 7 8 9

Output
0



-----Note-----

In the first sample, there are two ways to get a nice sequence with one swap:   Swap t_2 = 8 with t_4 = 7.  Swap t_1 = 2 with t_5 = 7. 

In the second sample, there is only one way — Limak should swap t_1 = 200 with t_4 = 50.

```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 = 'def get_bit(diff, i):\n    return 1 if ((i%2==1 and diff<=0) or (i%2==0 and diff>=0)) else 0\n\ndef swap_(i, j, a):\n    temp  = a[i]\n    a[i]  = a[j]\n    a[j]  = temp\n    \ndef swap(i, j, n, a, mask, S):\n    change = 0\n    swap_(i, j, a)\n    set_index = set([i, j])\n    \n    if i<n-1:\n        set_index.add(i+1)\n    \n    if j<n-1:\n        set_index.add(j+1)\n    \n    for index in set_index:\n        if index > 0:\n            diff    = a[index] - a[index-1] \n            bit_    = get_bit(diff, index)\n            change += bit_ - mask[index]\n        \n    swap_(i, j, a)    \n    if S + change == 0:\n        return 1\n    return 0    \n\nn     = int(input())\na     = list(map(int, input().split()))\n\ndiff  = [-1] + [x-y for x, y in zip(a[1:], a[:-1])]\nmask  = [get_bit(diff[i], i) for i in range(n)] \n\nS = sum(mask)\nfirst = -1\nfor i, x in enumerate(mask):\n    if x == 1:\n        first = i\n        break\n        \ncnt = 0\nfor second in range(n):\n    if swap(first, second, n, a, mask, S) == 1:\n        cnt += 1\n    \n    if first != 0 and swap(first-1, second, n, a, mask, S) == 1:\n        cnt += 1\n    \nif first!=0 and swap(first-1, first, n, a, mask, S) == 1:\n    cnt-=1\n    \nprint(cnt)    \n\n#9\n#1 2 3 4 5 6 7 8 9\n\n#10\n#3 2 1 4 1 4 1 4 1 4\n\n#4\n#200 150 100 50\n\n#5\n#2 8 4 7 7\n'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 13799