#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, flag = 0, floor = 0, p = 0;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (a[i] < a[j]) flag = 1;
      if (a[i] > a[j]) floor = 1;
      if (flag == 1 && floor == 1) {
        p++;
        flag = 0;
        floor = 0;
      }
    }
  }
  cout << p--;
  return 0;
}
