#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int a[maxn], n;
bool vis[maxn];
vector<int> l;
int ok(int pos) {
  if (pos % 2) {
    if (a[pos] >= a[pos - 1] || a[pos] >= a[pos + 1]) return 0;
  } else {
    if (a[pos] <= a[pos - 1] || a[pos] <= a[pos + 1]) return 0;
  }
  return 1;
}
void solve() {
  a[0] = maxn;
  if (n % 2)
    a[n + 1] = maxn;
  else
    a[n + 1] = -maxn;
  memset(vis, 0, sizeof(vis));
  for (int i = 1; i <= n; i++) {
    if (!ok(i))
      l.push_back(i);
    else
      vis[i] = 1;
  }
  if (l.size() > 6) {
    puts("0");
    return;
  }
  int cc = 0;
  int len = l.size();
  for (int i = 0; i < l.size(); i++) {
    int pos = l[i];
    for (int j = 1; j <= n; j++) {
      if (vis[j] || j < pos) {
        int tmp = 0;
        swap(a[pos], a[j]);
        if (!ok(j) || !ok(pos)) {
          swap(a[pos], a[j]);
          continue;
        }
        for (int k = 0; k < l.size(); k++) {
          if (ok(l[k])) tmp++;
        }
        if (tmp == len) {
          cc++;
        }
        swap(a[pos], a[j]);
      }
    }
  }
  printf("%d\n", cc);
}
int main() {
  while (scanf("%d", &n) != EOF) {
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    l.clear();
    solve();
  }
  return 0;
}
