#include <bits/stdc++.h>
using namespace std;
int a[100101];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  int i = 1;
  while (a[i] == a[0]) i++;
  int j = n - 2;
  while (a[n - 1] == a[j]) j--;
  cout << (j - i + 1 < 0 ? 0 : j - i + 1);
}
