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 = 'n = int(input())\nt = list(map(int, input().split()))\nt = [-1] + t\n\nbadIdx = []\nnice = []\ndef getBadIdx():\n    for i in range(1,n):\n        if ((i%2 == 0) and (t[i] <= t[i+1])) or ((i%2 == 1) and (t[i] >= t[i+1])):\n            badIdx.append((i,i+1))\n\ndef checkBad(k):\n    if ((k <= (n-1)) and (((k%2 == 0) and (t[k] <= t[k+1])) or ((k%2 == 1) and (t[k] >= t[k+1])))) \\\n        or ((k-1) >= 1 and (((k-1)%2 == 0) and (t[k-1] <= t[k]) or ((k-1)%2 == 1) and (t[k-1] >= t[k]))):\n            return True\n    for (i,j) in badIdx:\n        if ((i%2 == 0) and (t[i] <= t[j])) or ((i%2 == 1) and (t[i] >= t[j])):\n            return True\n    \n    return False\n\ndef swap(i,j):\n    ith = t[i]\n    t[i] = t[j]\n    t[j] = ith\n    \ngetBadIdx()\n\nif len(badIdx) > 4:\n    print(0)\nelse:\n    (i,j) = badIdx[0]\n    #for (i,j) in badIdx:\n    for k in range(1,n+1):\n        if i != k and t[i] != t[k]:\n            swap(i,k)\n            if not(checkBad(k)):\n                nice.append((i,k))\n                swap(i,k)\n            else:\n                swap(i,k)\n            \n        if j != k and t[j] != t[k]:\n            swap(j,k)\n            if not(checkBad(k)):\n                nice.append((j,k))\n                swap(j,k)\n            else:\n                swap(j,k)\n    \n    print(len(set([tuple(sorted(t)) for t in nice])))\n'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 13501