#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  if (n <= 2) {
    cout << 0;
  } else {
    sort(a.begin(), a.end());
    vector<int> res;
    res.push_back(a[0]);
    for (int i = 1; i < n; i++) {
      if (a[0] == a[i]) {
        continue;
      } else if (a[n - 1] == a[i] && i != n - 1) {
        continue;
      } else {
        res.push_back(a[i]);
      }
    }
    if (res.size() > 2) {
      cout << res.size() - 2;
    } else
      cout << 0;
  }
  return 0;
}
