#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, a, s = 1, e = 1;
  cin >> n;
  long long int arr[n];
  for (long long int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  sort(arr, arr + n);
  for (long long int i = 1; i < n; i++) {
    if (arr[i] == arr[i - 1])
      s++;
    else
      break;
  }
  for (long long int i = n - 1; i > 0; i--) {
    if (arr[i] == arr[i - 1])
      e++;
    else
      break;
  }
  if ((n - (s + e)) > 0)
    cout << n - (s + e);
  else
    cout << "0";
}
