#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int a[N];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  int l = 1, r = n - 1;
  for (int i = 1; i < n; i++) {
    if (a[i] != a[i - 1]) break;
    l++;
  }
  for (int i = n - 2; i >= 0; i--) {
    if (a[i] != a[i + 1]) break;
    r--;
  }
  cout << max(0, r - l);
  return 0;
}
