#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int ar[n];
  for (int i = 0; i < n; i++) {
    cin >> ar[i];
  }
  sort(ar, ar + n);
  if (n <= 2)
    cout << 0 << endl;
  else if (ar[1] > ar[0] && ar[n - 2] < ar[n - 1])
    cout << n - 2 << endl;
  else {
    int x = -1, y = -1;
    for (int i = 1; i < n; i++) {
      if (ar[i] != ar[0]) {
        x = i;
        break;
      }
    }
    for (int i = n - 2; i >= 0; i--) {
      if (ar[n - 1] != ar[i]) {
        y = i;
        break;
      }
    }
    if (x != -1 && y != -1)
      cout << y - x + 1 << endl;
    else
      cout << 0 << endl;
  }
}
