#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, min, max, minn = 1, maxn = 1, p = 0, t;
  cin >> n;
  cin >> min;
  max = min;
  for (int i = 1; i < n; i++) {
    cin >> t;
    if (t < min) {
      if (min < max) {
        p += minn;
      }
      min = t;
      minn = 1;
    } else if (t > max) {
      if (min < max) {
        p += maxn;
      }
      max = t;
      maxn = 1;
    } else if (t == min || t == max) {
      if (t == min) minn++;
      if (t == max) maxn++;
    } else {
      p++;
    }
  }
  cout << p;
}
