#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:640000000")
using namespace std;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int maxn = (int)15e4 + 10;
int t[maxn];
bool used[maxn];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) scanf("%d", &t[i]);
  set<int> bad;
  for (int i = 0; i + 1 < n; i++) {
    if (i % 2 == 0) {
      if (t[i] >= t[i + 1]) {
        bad.insert(i);
        bad.insert(i + 1);
      }
    } else {
      if (t[i] <= t[i + 1]) {
        bad.insert(i);
        bad.insert(i + 1);
      }
    }
  }
  if ((int)(bad).size() > 6) {
    cout << 0 << endl;
    return 0;
  }
  vector<int> v;
  for (__typeof((bad).begin()) it = (bad).begin(); it != (bad).end(); it++) {
    v.push_back(*it);
    used[*it] = true;
  }
  int res = 0;
  for (int i = 0; i < (int)(v).size(); i++) {
    for (int j = i + 1; j < (int)(v).size(); j++) {
      int x = v[i];
      int y = v[j];
      swap(t[x], t[y]);
      bool good = true;
      for (int k = 0; k + 1 < n; k++) {
        if (k % 2 == 0) {
          if (t[k] >= t[k + 1]) {
            good = false;
            break;
          }
        } else {
          if (t[k] <= t[k + 1]) {
            good = false;
            break;
          }
        }
      }
      if (good) res++;
      swap(t[x], t[y]);
    }
    bool all = true;
    for (int j = 0; j < (int)(v).size(); j++) {
      if (abs(v[i] - v[j]) > 1) {
        all = false;
        break;
      }
    }
    if (!all) continue;
    int x = v[i];
    for (int i = 0; i < n; i++)
      if (i != x && !used[i]) {
        swap(t[i], t[x]);
        bool good = true;
        for (int j = -1; j <= 0; j++) {
          int pos = i + j;
          if (pos < 0 || pos + 1 >= n) continue;
          if (pos % 2 == 0) {
            if (t[pos] >= t[pos + 1]) {
              good = false;
              break;
            }
          } else {
            if (t[pos] <= t[pos + 1]) {
              good = false;
              break;
            }
          }
        }
        for (int j = -1; j <= 0; j++) {
          int pos = x + j;
          if (pos < 0 || pos + 1 >= n) continue;
          if (pos % 2 == 0) {
            if (t[pos] >= t[pos + 1]) {
              good = false;
              break;
            }
          } else {
            if (t[pos] <= t[pos + 1]) {
              good = false;
              break;
            }
          }
        }
        if (good) res++;
        swap(t[i], t[x]);
      }
  }
  cout << res << endl;
  return 0;
}
