#include <bits/stdc++.h>
using namespace std;
void solve() {}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  vector<int> A(t);
  for (int &i : A) cin >> i;
  if (t == 1) {
    cout << 0 << "\n";
  } else {
    map<int, int> set;
    for (int i = 0; i < t; i++) {
      set[A[i]]++;
    }
    if (set.size() == 1)
      cout << 0 << "\n";
    else
      cout << A.size() - (*set.begin()).second - (*set.rbegin()).second << "\n";
  }
  return 0;
}
