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