#include <bits/stdc++.h>
const int MAXN = 150005;
const int INF = 1500000;
using namespace std;
int n, a[MAXN];
vector<int> v;
bool yes[MAXN];
int scan() {
  int t = 0, m = 1;
  char c;
  c = getchar();
  while ((c < '0' || c > '9') and c != '-') c = getchar();
  if (c == '-') c = getchar(), m = -1;
  while (c >= '0' && c <= '9') t = (t << 3) + (t << 1) + c - '0', c = getchar();
  return (t * m);
}
bool judge(int x) {
  if (x < 1 || x == n) return true;
  if (x % 2 == 0 && a[x] > a[x + 1]) return true;
  if (x % 2 == 1 && a[x] < a[x + 1]) return true;
  return false;
}
int main() {
  n = scan();
  for (int i = 1; i <= n; i++) a[i] = scan();
  for (int i = 1; i <= n; i++) {
    if (!judge(i)) yes[i] = yes[i + 1] = true;
  }
  for (int i = 1; i <= n; i++)
    if (yes[i]) v.push_back(i);
  if (v.size() > 6) {
    cout << 0;
    return 0;
  }
  long long res = 0;
  for (int i = 1; i <= n; i++)
    if (yes[i])
      for (int j = 1; j <= n; j++) {
        if (j > i || !yes[j]) {
          swap(a[i], a[j]);
          if (judge(i - 1) && judge(i) && judge(j - 1) && judge(j)) {
            for (int k = 0; k < v.size(); k++)
              if (!judge(v[k])) goto stop;
            res++;
          }
        stop:
          swap(a[i], a[j]);
        }
      }
  cout << res;
  return 0;
}
