#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> v;
  int n, a, b;
  while (scanf("%d", &n) != EOF) {
    v.assign(n, 0);
    for (int i = 0; i < n; i++) {
      scanf("%d", &v[i]);
    }
    sort(v.begin(), v.end());
    a = 1;
    b = n - 1;
    while (a < n && v[a] == v[0]) a++;
    while (b >= 0 && v[b] == v[n - 1]) b--;
    if (a > b)
      printf("0\n");
    else
      printf("%d\n", b - a + 1);
  }
  return 0;
}
