#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const int INF = (1 << 29) + 5;
const long long int LLINF = (1ll << 59) + 5;
const int MOD = 1000 * 1000 * 1000 + 7;
int n;
int arr[228228];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &arr[i]);
  }
  sort(arr, arr + n);
  int ans = n - 2;
  int ptr = 0;
  while (ptr < n - 1 && arr[ptr] == arr[ptr + 1]) {
    ++ptr;
    --ans;
  }
  ptr = n - 1;
  while (ptr > 0 && arr[ptr - 1] == arr[ptr]) {
    --ptr;
    --ans;
  }
  printf("%d", max(ans, 0));
  fclose(stdin);
  fclose(stdout);
  return 0;
}
