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