#include <bits/stdc++.h>
using namespace std;
long long int a[100005];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
  }
  if (n == 1 || n == 2) {
    cout << 0 << endl;
    return 0;
  }
  sort(a, a + n);
  int i = 1, j = n - 2;
  while (i < n && a[i] == a[0]) {
    i++;
  }
  while (j >= 0 && a[j] == a[n - 1]) {
    j--;
  }
  if (i <= j) {
    cout << j - i + 1 << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}
