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 = "3\n\n\ndef needs_rep(t, i):\n\tif i % 2 == 0:\n\t\treturn t[i] >= t[i+1]\n\telse:\n\t\treturn t[i] <= t[i+1]\n\ndef would_need_rep(t, i, j1, j2):\n\tn = len(t)\n\tif i < 0:\n\t\treturn False\n\tif i >= n-1:\n\t\treturn False\n\n\ttj1 = t[j2]\n\ttj2 = t[j1]\n\n\tti = t[i]\n\tif i == j1:\n\t\tti = tj1\n\tif i == j2:\n\t\tti = tj2\n\n\tti1 = t[i+1]\n\tif i+1 == j1:\n\t\tti1 = tj1\n\tif i+1 == j2:\n\t\tti1 = tj2\n\n\tif i % 2 == 0:\n\t\treturn ti >= ti1\n\telse:\n\t\treturn ti <= ti1\n\n\ndef main():\n\tn = int(input())\n\tt = [int(i) for i in input().split()]\n\n\t# rep = [False]*(n-1)\n\trep = []\n\tfor i in range(n-1):\n\t\tif needs_rep(t, i):\n\t\t\trep.append(i)\n\n\tif(len(rep) > 4):\n\t\tprint(0)\n\t\treturn\n\n\t# print(rep)\n\n\t# to_try = [rep[0]]\n\t# if rep[0] < n-1:\n\t# \tto_try.append(rep[0] + 1)\n\tto_try = [rep[0], rep[0] + 1]\n\n\ts = set()\n\n\tfor i in to_try:\n\t\tfor j in range(n):\n\t\t\tif i == j: continue\n\n\t\t\tif would_need_rep(t, i, i, j):\n\t\t\t\tcontinue\n\t\t\tif would_need_rep(t, i-1, i, j):\n\t\t\t\tcontinue\n\t\t\tif would_need_rep(t, j, i, j):\n\t\t\t\tcontinue\n\t\t\tif would_need_rep(t, j-1, i, j):\n\t\t\t\tcontinue\n\n\t\t\tbad = False\n\t\t\tfor r in rep:\n\t\t\t\tif would_need_rep(t, r, i, j):\n\t\t\t\t\tbad = True\n\t\t\tif bad: continue\n\n\t\t\t# print(i, j)\n\t\t\t# print(would_need_rep(t, 2, i, j))\n\n\t\t\tif (i, j) not in s and (j, i) not in s:\n\t\t\t\t# print('Adding {}'.format((i, j)))\n\t\t\t\ts.add((i, j))\n\n\tprint(len(s))\n\n\ndef __starting_point():\n\tmain()\n\n__starting_point()"
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 14623