#include <bits/stdc++.h>
using namespace std;
vector<long long int> A;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  A.clear();
  long long int n, i, j, ans = 0, temp, len, mini, maxi;
  cin >> n;
  len = n;
  for (i = 0; i < n; i++) {
    cin >> temp;
    A.push_back(temp);
  }
  if (n < 3) {
    cout << "0\n";
    return 0;
  }
  sort(A.begin(), A.end());
  mini = A[0];
  maxi = A[n - 1];
  i = 0;
  temp = 0;
  while (i < n) {
    if (A[i] == mini)
      temp++;
    else
      break;
    i += 1;
  }
  i = n - 1;
  while (i >= 0) {
    if (A[i] == maxi)
      temp++;
    else
      break;
    i -= 1;
  }
  ans = n - temp;
  if (ans < 0) ans = 0;
  cout << ans << "\n";
  return 0;
}
