#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  int low = 0, high = n - 1;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  if (n <= 2) {
    cout << 0 << endl;
    return 0;
  }
  for (int j = 0; j < n - 1; j++) {
    if (a[j] == a[j + 1])
      low++;
    else
      break;
  }
  for (int k = n - 1; k >= 1; k--) {
    if (a[k] == a[k - 1])
      high--;
    else
      break;
  }
  if (low >= high)
    cout << 0 << endl;
  else
    cout << high - low - 1 << endl;
}
