"Night gathers, and now my watch begins. It shall not end until my death. I shall take no wife, hold no lands, father no children. I shall wear no crowns and win no glory. I shall live and die at my post. I am the sword in the darkness. I am the watcher on the walls. I am the shield that guards the realms of men. I pledge my life and honor to the Night's Watch, for this night and all the nights to come." — The Night's Watch oath.

With that begins the watch of Jon Snow. He is assigned the task to support the stewards.

This time he has n stewards with him whom he has to provide support. Each steward has his own strength. Jon Snow likes to support a steward only if there exists at least one steward who has strength strictly less than him and at least one steward who has strength strictly greater than him.

Can you find how many stewards will Jon support?


-----Input-----

First line consists of a single integer n (1 ≤ n ≤ 10^5) — the number of stewards with Jon Snow.

Second line consists of n space separated integers a_1, a_2, ..., a_{n} (0 ≤ a_{i} ≤ 10^9) representing the values assigned to the stewards.


-----Output-----

Output a single integer representing the number of stewards which Jon will feed.


-----Examples-----
Input
2
1 5

Output
0
Input
3
1 2 5

Output
1


-----Note-----

In the first sample, Jon Snow cannot support steward with strength 1 because there is no steward with strength less than 1 and he cannot support steward with strength 5 because there is no steward with strength greater than 5.

In the second sample, Jon Snow can support steward with strength 2 because there are stewards with strength less than 2 and greater than 2.

Source: codeforces | Difficulty: EASY
Tags: Sorting

Constructive algorithms


Solutions:
n = int(input())
a = list(map(int, input().split()))
a.sort()
try:
	while a[0] == a[1]:
		a.pop(0)
		n -= 1
	while a[n - 1] == a[n - 2]:
		a.pop(n - 2)
		n -= 1
	print(n - 2)
except:
	print(0)


n = int(input())
stds = list(map(int, input().split()))
mx = max(stds)
mn = min(stds)
if n < 3:
	print(0)
else:
	counter = 0
	for i in stds:
		if mn < i < mx:
			counter += 1
	print(counter)


n = int(input())
a = [int(i) for i in input().split(' ')]
x = min(a)
y = max(a)
c = 0
for i in range(n):
	if a[i] > x and a[i] < y:
		c += 1
print(c)


n = int(input())
a = map(int, input().split(' '))
least = float('inf')
most = float('-inf')
cache = {}
for ai in a:
	cache[ai] = cache[ai] + 1 if ai in cache else 1
	least = min(least, ai)
	most = max(most, ai)
del cache[least]
if least != most:
	del cache[most]
res = sum(cache.values())
print(res)


n = input()
xs = list(map(int, input().split()))
counts = {}
for x in xs:
	counts[x] = counts.get(x, 0) + 1
middle = sorted(counts.items(), key=lambda tup: tup[0])[1:-1]
counts = [c for (_, c) in middle]
print(sum(counts))


n = int(input())
a = list(map(int, input().split()))
ans = max(0, len(a) - a.count(min(a)) - a.count(max(a)))
print(ans)


n = int(input())
x = list(map(int, input().split()))
print(max(0, n - x.count(min(x)) - x.count(max(x))))


n = int(input())
s = input()
A = []
for i in s.split():
	A.append(int(i))
Min = min(A)
Max = max(A)
a = A.count(Min)
b = A.count(Max)
if n > 2 and a != n:
	print(n - a - b)
else:
	print(0)


n = int(input())
a = list(map(int, input().split()))
q = 0
mx = max(a)
mn = min(a)
q = 0
for i in a:
	if i < mx and i > mn:
		q += 1
print(q)


import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
q = min(a)
z = max(a)
ans = 0
for i in range(n):
	if q < a[i] < z:
		ans += 1
print(ans)


n = int(input())
l = sorted(list(map(int, input().split())))
if n <= 2:
	print(0)
else:
	mini = min(l)
	maxi = max(l)
	if mini == maxi:
		print(0)
	else:
		c_mini = 0
		c_maxi = 0
		for e in l:
			if e == mini:
				c_mini += 1
			if e == maxi:
				c_maxi += 1
		print(n - c_mini - c_maxi)


from collections import defaultdict
n = int(input())
li = list(map(int, input().split()))
d = defaultdict(int)
for i in li:
	d[i] += 1
c = 0
li1 = sorted(list(set(li)))
for i in range(len(li1)):
	if i != 0 and i != len(li1) - 1:
		if li1[i - 1] < li1[i] < li1[i + 1]:
			c += d[li1[i]]
print(c)


n = int(input())
myStr = map(int, input().split())
myStr = list(myStr)
myStr.sort()
counter = 0
for i in range(len(myStr)):
	if myStr[i] > myStr[0] and myStr[i] < myStr[-1]:
		counter += 1
print(counter)


c = int(input())
x = input().split()
nums = []
for item in x:
	nums.append(int(item))
out = len(nums) - nums.count(min(nums)) - nums.count(max(nums))
if out < 0:
	print(0)
else:
	print(out)


def shellSort(arr):
	n = len(arr)
	gap = n // 2
	while gap > 0:
		for i in range(gap, n):
			temp = arr[i]
			j = i
			while j >= gap and arr[j - gap] > temp:
				arr[j] = arr[j - gap]
				j -= gap
			arr[j] = temp
		gap //= 2
steward = int(input())
strengths = list(map(int, input().split()))
shellSort(strengths)
low = min(strengths)
high = max(strengths)
supportable = 0
for i in range(steward):
	if low < strengths[i] < high:
		supportable = supportable + 1
print(supportable)


n = int(input())
a = list(map(int, input().split()))
print((0, len(a) - a.count(max(a)) - a.count(min(a)))[len(set(a)) > 2])


def code(n, arr):
	if n == 1 or n == 2:
		return 0
	else:
		count = 0
		arr.sort()
		for i in range(len(arr)):
			if arr[i] == arr[0] or arr[i] == arr[len(arr) - 1]:
				count = count + 1
	return len(arr) - count
n = int(input())
arr = list(map(int, input().split()))
print(code(n, arr))


n = int(input())
stewards = [int(v) for v in input().split(' ')]
max = 0
min = 10 ** 9 + 1
for s in stewards:
	if s > max:
		max = s
	if s < min:
		min = s
for s in stewards:
	if s == max or s == min:
		n -= 1
print(n)


n = int(input())
a = [int(w) for w in input().split()]
a = sorted(a)
a = len([w for w in a if w != a[0] and w != a[-1]])
print(a)


n = int(input())
l = [int(x) for x in input().split()]
l.sort()
mi = l[0]
ma = l[len(l) - 1]
(i, j) = (0, len(l) - 1)
while i < len(l) and l[i] == mi:
	i += 1
while j > -1 and l[j] == ma:
	j -= 1
print(int(j >= i and j != -1 and (i != len(l))) * (j - i + 1))


input()
ls = list(map(int, input().split()))
mx = max(ls)
mn = min(ls)
ans = 0
for x in ls:
	ans += mn < x < mx
print(ans)


n = int(input())
l = list(map(int, input().split()))
l.sort()
min = l[0]
max = l[-1]
Ans = []
for x in l:
	if x > min and x < max:
		Ans.append(x)
print(len(Ans))


n = int(input())
strength = input()
strength = strength.split(' ')
strengthlist = []
for s in strength:
	strengthlist.append(int(s))
ssorted = strengthlist[:]
ssorted.sort()
support = 0
if n <= 2:
	support = 0
else:
	for i in range(0, n):
		sup1 = 0
		sup2 = 0
		if ssorted[0] != strengthlist[i]:
			sup1 = 1
		if ssorted[-1] != strengthlist[i]:
			sup2 = 1
		if sup1 + sup2 == 2:
			support = support + 1
print(support)


from sys import stdin, stdout
import bisect
from bisect import bisect_left as bl
from bisect import bisect_right as br
import itertools
from collections import Counter
import collections
import math
import heapq
import re

def modinv(n, p):
	return pow(n, p - 2, p)

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l

def most_frequent(list):
	return max(set(list), key=list.count)

def GCD(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def ncr(n, r, p):
	t = fact[n] * (ifact[r] * ifact[n - r] % p) % p
	return t

def Convert(string):
	li = list(string.split(''))
	return li

def SieveOfEratosthenes(n):
	global prime
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	f = []
	for p in range(2, n):
		if prime[p]:
			f.append(p)
	return f
prime = []
q = []

def dfs(n, d, v, c):
	global q
	v[n] = 1
	x = d[n]
	q.append(n)
	j = c
	for i in x:
		if i not in v:
			f = dfs(i, d, v, c + 1)
			j = max(j, f)
	return j

def main():
	n = inin()
	a = ain()
	if len(set(a)) <= 2:
		print(0)
	else:
		a.sort()
		length = len(a)
		temp1 = a[0]
		temp2 = a[-1]
		i = 0
		if a[0] != a[-1]:
			while i < length:
				if a[i] == temp1:
					a.remove(a[i])
					length = length - 1
					continue
				elif a[i] == temp2:
					a.remove(a[i])
					length -= 1
					continue
				i = i + 1
			print(length)
		else:
			print(0)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


n = int(input())
x = list(map(int, input().split()))
minx = min(x)
maxx = max(x)
print(len([i for i in x if i > minx and i < maxx]))


n = int(input())
l = list(map(int, input().split()))
mn = min(l)
mx = max(l)
count = 0
for i in l:
	if i > mn and i < mx:
		count += 1
print(count)


n = int(input())
a = sorted(list(map(int, input().split())))
max_el = a[-1]
min_el = a[0]
b = list(set(a))
count = 0
if len(b) <= 2:
	count += 0
else:
	for i in range(n):
		if a[i] < max_el and a[i] > min_el:
			count += 1
print(count)


input()
l = sorted(map(int, input().split()))
print(max(0, len(l) - l.count(l[0]) - l.count(l[-1])))


import sys

def steward():
	num = sys.stdin.readline()
	stewards = sys.stdin.readline().split(' ')
	if stewards[-1] == '\n':
		stewards.pop()
	else:
		stewards[-1].rstrip()
	stewards = [int(x) for x in stewards]
	stewards.sort()
	(minn, maxx) = (stewards[0], stewards[-1])
	stewards = list(filter(lambda x: x < maxx and x > minn, stewards))
	return len(stewards)
print(steward())


n = int(input())
stewards = list(map(int, input().split()))
if len(stewards) < 3:
	print(0)
else:
	count = 0
	weakest = min(stewards)
	strongest = max(stewards)
	for man in stewards:
		if weakest < man < strongest:
			count += 1
	print(count)


x = int(input())
y = [int(i) for i in input().split()]
b = max(y)
a = min(y)
for i in y:
	if a == i:
		x -= 1
for i in y[::-1]:
	if b == i:
		x -= 1
if x < 0:
	x = 0
print(x)


n = int(input())
l = list(map(int, input().split()))
print(max(0, n - l.count(min(l)) - l.count(max(l))))


n = int(input())
l = [int(i) for i in input().split()]
d = {}
for i in l:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
s = set(l)
print(max(n - d[min(s)] - d[max(s)], 0))


n = int(input())
l = sorted([int(i) for i in input().split()])
k1 = 0
k2 = n - 1
for i in range(n - 2, -1, -1):
	if l[i] == l[n - 1]:
		k2 -= 1
for i in range(1, n):
	if l[i] == l[0]:
		k1 += 1
print(max(0, k2 - k1 - 1))


n = int(input())
strenghts = [int(s) for s in input().split()]
minimum = min(strenghts)
maximum = max(strenghts)
count = 0
for i in range(n):
	if minimum < strenghts[i] < maximum:
		count += 1
print(count)


n = int(input())
b = list(map(int, input().split()))
count = 0
if len(b) <= 2:
	print(count)
else:
	b.sort()
	low = b[0]
	high = b[-1]
	for i in range(n):
		if b[i] > low and b[i] < high:
			count += 1
	print(count)


n = int(input())
a = list(map(int, input().split()))
s = set(a)
if len(s) > 2:
	a.sort()
	x = a[0]
	y = a[-1]
	i = 1
	j = -2
	while a[i] == x:
		i += 1
	while a[j] == y:
		j -= 1
	print(n - i + j + 1)
else:
	print(0)


n = int(input())
data = list(map(int, input().split()))
d = {}
for v in data:
	d[v] = d.get(v, 0) + 1
mp = max(data)
mm = min(data)
if mm < mp:
	print(n - d[mp] - d[mm])
else:
	print(0)


n = int(input())
l = list(map(int, input().split(' ')))
res = 0
l.sort()
for i in range(1, n - 1):
	if l[i] > l[0] and l[i] < l[n - 1]:
		res += 1
print(res)


n = int(input())
a = list(map(int, input().split()))
r = 0
a.sort()
for i in range(n):
	if a[i] == a[0]:
		r += 1
	elif a[i] == a[-1]:
		r += 1
print(n - r)


D = int(input())
K = [int(d) for d in input().split(' ')]
c = 0
Z = sorted(K)
for i in Z:
	if Z[0] < i < Z[-1]:
		c += 1
print(c)


n = int(input())
a = list(map(int, input().split()))
(a1, a2) = (max(a), min(a))
if len(set(a)) == 1 or len(set(a)) == 2:
	print(0)
else:
	while True:
		if a1 in a:
			a.remove(a1)
		if a2 in a:
			a.remove(a2)
		elif a1 not in a and a2 not in a:
			break
	print(len(a))


n = int(input())
a = list(map(int, input().split()))
a.sort()
m = a[0]
ind = 1
while ind < n and a[ind] == m:
	ind += 1
end = a[-1]
ind2 = n - 1
while ind2 >= 0 and a[ind2] == end:
	ind2 -= 1
print(max(0, 1 + ind2 - ind))


n = int(input())
a = list(map(int, input().split()))
m = a.count(max(a))
mn = a.count(min(a))
print(max(0, n - m - mn))


n = int(input())
stuards = list(map(int, input().split()))
mini = max(stuards)
maxi = min(stuards)
s = 0
for i in stuards:
	if i != mini and i != maxi:
		s += 1
print(s)


n = int(input())
ls = list(map(int, input().split()))
ls.sort()
(mn, mx, sum) = (ls[0], ls[-1], 0)
for i in ls:
	if i > mn and i < mx:
		sum += 1
print(sum)


n = int(input())
a = [int(x) for x in input().split(' ')]
count = 0
if n == 2:
	print(0)
else:
	least = min(a)
	largest = max(a)
	for x in a:
		if not (x == least or x == largest):
			count += 1
	print(count)


3
n = int(input())
A = list(map(int, input().split()))
mn = min(A)
mx = max(A)
ans = 0
for x in A:
	if mn < x < mx:
		ans += 1
print(ans)


b = int(input())
a = sorted(list(map(int, input().split())))
c = 0
for i in a:
	if a[0] < i < a[-1]:
		c += 1
print(c)


import unittest
import sys

class Oath:

	def __init__(self, test_inputs=None):
		it = iter(test_inputs.split('\n')) if test_inputs else None

		def uinput():
			return next(it) if it else sys.stdin.readline().rstrip()
		[self.n] = map(int, uinput().split())
		self.nums = list(map(int, uinput().split()))

	def calculate(self):
		result = 0
		mx = max(self.nums)
		mn = min(self.nums)
		result = len([a for a in self.nums if a != mx and a != mn])
		return str(result)

class unitTests(unittest.TestCase):

	def test_single_test(self):
		test = '2\n1 5\n'
		d = Oath(test)
		self.assertEqual(d.n, 2)
		self.assertEqual(d.nums, [1, 5])
		self.assertEqual(Oath(test).calculate(), '0')
		test = '3\n1 2 5\n'
		self.assertEqual(Oath(test).calculate(), '1')
		test = '1\n5 5 5 2 2 2 2 3'
		self.assertEqual(Oath(test).calculate(), '1')
		test = ''

	def time_limit_test(self, nmax):
		import random
		import timeit
		test = str(nmax) + ' ' + str(nmax) + '\n'
		numnums = [str(i) + ' ' + str(i + 1) for i in range(nmax)]
		test += '\n'.join(numnums) + '\n'
		nums = [random.randint(1, 10000) for i in range(nmax)]
		test += ' '.join(map(str, nums)) + '\n'
		start = timeit.default_timer()
		d = Oath(test)
		calc = timeit.default_timer()
		d.calculate()
		stop = timeit.default_timer()
		print('\nTimelimit Test: ' + '{0:.3f}s (init {1:.3f}s calc {2:.3f}s)'.format(stop - start, calc - start, stop - calc))
sys.setrecursionlimit(100000)
if sys.argv[-1] == '-ut':
	unittest.main(argv=[' '])
sys.stdout.write(Oath().calculate())


n = int(input())
stewards = list(map(int, input().split()))
stewards.sort()
lowest_val = stewards[0]
highest_val = stewards[n - 1]
total_people = n
for i in range(0, n):
	if stewards[i] == lowest_val or stewards[i] == highest_val:
		total_people -= 1
print(total_people)


n = int(input())
a = list(map(int, input().split()))
(mi, ma) = (a.count(min(a)), a.count(max(a) if max(a) != min(a) else -1))
print(n - mi - ma)


n = input()
l = [int(i) for i in input().split()]
l_s = list(set(l))
if len(l_s) >= 3:
	print(len(l) - l.count(max(l)) - l.count(min(l)))
else:
	print(0)


from sys import stdin, stdout, maxsize
tup = lambda : map(int, stdin.readline().split())
I = lambda : int(stdin.readline())
lint = lambda : [int(x) for x in stdin.readline().split()]
stpr = lambda x: stdout.write(f'{x}' + '\n')
star = lambda x: print(' '.join(map(str, x)))
from bisect import bisect_left, bisect_right
n = I()
ls = lint()
(mi, ma, cnt1, cnt2, c) = (min(ls), max(ls), 0, 0, 0)
for i in range(n):
	if ls[i] > mi:
		cnt1 += 1
		c += 1
	if ls[i] < ma:
		cnt2 += 1
		c += 1
if mi == ma:
	print(0)
else:
	print(abs(n - c))


def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def loadinput():
	n = int(input())
	arr = list(map(int, input().split()))
	return arr

def checkstews(arr):
	if len(arr) <= 2:
		return 0
	if len(set(arr)) == 1:
		return 0
	noofmax = arr.count(max(arr))
	noofmin = arr.count(min(arr))
	arr.remove(min(arr))
	arr.remove(max(arr))
	if noofmax > 1 and noofmin > 1:
		count = len(arr) - (noofmax - 1) - (noofmin - 1)
	elif noofmax > 1 and noofmin == 1:
		count = len(arr) - (noofmax - 1)
	elif noofmin > 1 and noofmax == 1:
		count = len(arr) - (noofmin - 1)
	else:
		count = len(arr)
	return count
arr = loadinput()
ans = checkstews(arr)
print(ans)


n = int(input())
A = list(map(int, input().split()))
x1 = A.count(min(A))
x2 = A.count(max(A))
print(max(0, n - x1 - x2))


n = int(input())
s = list(map(int, input().split()))
s1 = list(set(s))
s1.sort()
if len(s1) > 2:
	c = s.count(s1[0])
	c += s.count(s1[len(s1) - 1])
	print(n - c)
else:
	print(0)


n = int(input())
stuards = [int(x) for x in input().split()]
ans = 0
(mn, mx) = (min(stuards), max(stuards))
for i in stuards:
	if i == mn or i == mx:
		continue
	else:
		ans += 1
print(ans)


n = int(input())
L = list(map(int, input().split()))
mx = max(L)
mn = min(L)
cnt = 0
for x in L:
	if x != mx and x != mn:
		cnt += 1
print(cnt)


def editorial(a):
	min_elem = min(a)
	max_elem = max(a)
	st = 0
	for x in a:
		if min_elem < x < max_elem:
			st += 1
	return st
n = int(input())
a = [int(x) for x in input().split()]
print(editorial(a))


from sys import stdin, stdout
from collections import defaultdict
import heapq

def get_int():
	return int(stdin.readline().strip())

def get_ints():
	return map(int, stdin.readline().strip().split())

def get_array():
	return list(map(int, stdin.readline().strip().split()))

def get_string():
	return stdin.readline().strip()
INF = 10000000000.0
n = get_int()
a = get_array()
f = max(a)
l = min(a)
d = defaultdict(int)
for i in a:
	d[i] += 1
ans = 0
for i in d:
	if i == f or i == l:
		continue
	ans += d[i]
print(ans)


a = int(input())
s = [int(i) for i in input().split()]
d = set(s)
if len(d) < 2:
	print(0)
else:
	print(len(s) - s.count(max(s)) - s.count(min(s)))


def inp():
	return map(int, input().split())

def arr_inp():
	return [int(x) for x in input().split()]

def print_arr(arr):
	print(*arr, sep=' ')
n = int(input())
a = arr_inp()
a.sort()
sum = 0
for i in range(1, n - 1):
	if a[0] < a[i] and a[n - 1] > a[i]:
		sum += 1
print(sum)


n = input()
force = input()
force = force.split(' ')
force = list(map(lambda x: int(x), force))
mine = force[0]
maxe = force[0]
cnt = 0
for i in force:
	if i < mine:
		mine = i
	if i > maxe:
		maxe = i
for i in force:
	if i == mine or i == maxe:
		cnt += 1
print(int(n) - cnt)


n = int(input(''))
a = sorted(list(map(int, input('').split())))
mini = a[0]
maxi = a[-1]
meg = 0
for j in a:
	if j > mini and j < maxi:
		meg += 1
print(meg)


import sys
n = int(input().strip())
li = list(map(int, input().strip().split()))
(mx, mn) = (max(li), min(li))
if mx != mn:
	print(len(li) - li.count(mn) - li.count(mx))
else:
	print(0)


def nextGap(gap):
	gap = gap * 10 // 13
	if gap < 1:
		return 1
	return gap

def combSort(arr):
	n = len(arr)
	gap = n
	swapped = True
	while gap != 1 or swapped:
		gap = nextGap(gap)
		swapped = False
		for i in range(0, n - gap):
			if arr[i] > arr[i + gap]:
				(arr[i], arr[i + gap]) = (arr[i + gap], arr[i])
				swapped = True
size = int(input())
arr = [int(x) for x in input().split()]
combSort(arr)
unsupportable = 0
for x in arr:
	if x == arr[0]:
		unsupportable += 1
	else:
		break
for x in reversed(arr):
	if x == arr[len(arr) - 1]:
		unsupportable += 1
	else:
		break
print(size - unsupportable if size - unsupportable >= 0 else 0)


def next_gap(gap):
	gap = gap * 10 // 13
	if gap < 1:
		return 1
	return gap

def comb_sort(arr):
	n = len(arr)
	gap = n
	swapped = True
	while gap != 1 or swapped:
		gap = next_gap(gap)
		swapped = False
		for i in range(0, n - gap):
			if arr[i] > arr[i + gap]:
				(arr[i], arr[i + gap]) = (arr[i + gap], arr[i])
				swapped = True
n = int(input())
x = list(map(int, input().split()))
comb_sort(x)
cant_support = 0
for i in x:
	if i == x[0]:
		cant_support = cant_support + 1
	else:
		break
for i in reversed(x):
	if i == x[len(x) - 1]:
		cant_support = cant_support + 1
	else:
		break
if n - cant_support >= 0:
	print(n - cant_support)
else:
	print(0)


n = int(input())
arr = [int(ele) for ele in input().split()]
a = max(arr)
b = min(arr)
count = 0
for i in arr:
	if i < a and i > b:
		count += 1
print(count)


n = int(input())
a = [int(i) for i in input().split()]
a.sort()
res1 = 0
res2 = 0
if a[0] == a[-1]:
	print(0)
else:
	for i in a:
		if i == a[0]:
			res1 += 1
		else:
			break
	for i in range(1, n):
		if a[-i] == a[-1]:
			res2 += 1
		else:
			break
	print(n - res1 - res2)


n = int(input())
arr = list(map(int, input().split()))
arr.sort()
count = 0
for _ in range(1, n - 1):
	if arr[_] > arr[0] and arr[-1] > arr[_]:
		count += 1
print(count)


n = int(input())
stewards = [int(x) for x in input().split()]
min = 9999999999
max = -1
answer = 0
for i in stewards:
	if i > max:
		max = i
	if i < min:
		min = i
for i in stewards:
	if i > min and i < max:
		answer += 1
print(answer)


n = int(input())
s = list(map(int, input().split()))
if len(list(set(s))) <= 2:
	print(0)
	exit()
s.sort()
i = 0
j = n - 1
while s[i] == s[0] and i < n:
	i += 1
while s[j] == s[-1] and j >= 0:
	j -= 1
print(j - i + 1)


m = input()
n = list(map(int, input().split()))
n.sort()
amax = n[-1]
bmin = n[0]
count = 0
for i in n[1:-1]:
	if i != amax and i != bmin:
		count += 1
print(count)


n = int(input())
A = [int(x) for x in input().split(' ')]
count = 0
mn = A[0]
mx = 0
for i in range(1, len(A)):
	if A[i] > mx:
		mx = A[i]
	if A[i] < mn:
		mn = A[i]
for i in range(len(A)):
	if A[i] > mn and A[i] < mx:
		count += 1
print(count)


x = int(input())
l = list(map(int, input().split()))
mi = min(l)
mx = max(l)
f = 0
c = 0
for i in l:
	if mi < i and i < mx:
		c += 1
		f = 1
print(c)


n = int(input())
l = list(map(int, input().split()))
l.sort()
a = l[0]
b = l[-1]
l = list(filter(lambda x: x != a and x != b, l))
print(len(l))


from sys import stdin, stdout, maxsize
tup = lambda : map(int, stdin.readline().split())
I = lambda : int(stdin.readline())
lint = lambda : [int(x) for x in stdin.readline().split()]
stpr = lambda x: stdout.write(f'{x}' + '\n')
star = lambda x: print(' '.join(map(str, x)))
from bisect import bisect_left, bisect_right
n = I()
ls = lint()
ls.sort()
cnt = 0
for i in range(1, n - 1):
	if ls[i - 1] < ls[i] < ls[i + 1]:
		cnt += 1
	else:
		a = bisect_left(ls, ls[i])
		c = bisect_right(ls, ls[i])
		try:
			if ls[a - 1] < ls[i] < ls[c]:
				cnt += 1
				continue
		except:
			continue
print(cnt)


n = int(input())
l = list(map(int, input().split()))
l.sort()
s1 = [0 for i in range(n)]
s1[0] = -1
i = 1
while i < n:
	if l[i - 1] < l[i]:
		s1[i] = i - 1
	else:
		s1[i] = s1[i - 1]
	i += 1
s2 = [0 for i in range(n)]
s2[n - 1] = -1
i = n - 2
while i >= 0:
	if l[i] < l[i + 1]:
		s2[i] = i + 1
	else:
		s2[i] = s2[i + 1]
	i -= 1
t = 0
for i in range(n):
	if s1[i] != -1 and s2[i] != -1:
		t += 1
print(t)


n = int(input())
l = sorted([int(i) for i in input().split()])
x = l[0]
y = l[n - 1]
print(max(n - l.count(x) - l.count(y), 0))


a = int(input())
b = input()
c = 0
bb = [int(k) for k in b.split(' ')]
minimal = bb[0]
maximal = bb[0]
for i in range(a):
	if minimal > bb[i]:
		minimal = bb[i]
	if maximal < bb[i]:
		maximal = bb[i]
for i in range(a):
	if bb[i] != minimal and bb[i] != maximal:
		c = c + 1
print(c)


n = int(input())
a = [int(x) for x in input().split(' ')]
a = sorted(a)
v1 = n - a.index(a[-1])
a.reverse()
v2 = n - a.index(a[-1])
count = n - v1 - v2
if count > 0:
	print(count)
else:
	print(0)


n = int(input())
strengths = list(map(int, input().split()))
maximum = max(strengths)
minimum = min(strengths)
count = 0
for s in strengths:
	if minimum < s < maximum:
		count += 1
print(count)


n = int(input())
lst = [int(i) for i in input().split()]
(minimum, maximum) = (min(lst), max(lst))
result = 0
for elem in lst:
	if minimum != elem != maximum:
		result += 1
print(result)


n = int(input())
l = [int(i) for i in input().split()]
l.sort()
if n < 3:
	print('0')
else:
	min = l[0]
	max = l[n - 1]
	c = 0
	for i in range(1, n - 1):
		if l[i] > min and l[i] < max:
			c = c + 1
	print(c)


x = int(input())
lst = list(map(int, input().split()))
lst.sort()
cnt = 0
for i in range(1, x - 1):
	if lst[0] < lst[i] and lst[x - 1] > lst[i]:
		cnt += 1
print(cnt)


n = int(input())
q = [int(x) for x in input().split()]
q.sort()
ans = 0
for i in range(1, n - 1):
	if q[0] < q[i] < q[n - 1]:
		ans += 1
print(ans)


x = input()
x = list(map(int, input().strip().split()))
x.sort()
minimum = x[0]
maximum = x[len(x) - 1]
count = 0
for i in range(0, len(x)):
	if x[i] >= minimum + 1 and x[i] <= maximum - 1:
		count += 1
print(count)


n = int(input())
p = sorted(map(int, input().split()))
r = 0
for x in p:
	if p[0] < x < p[-1]:
		r += 1
print(r)


import sys
import math
import bisect
import itertools
import random
import re

def solve(A):
	min_val = min(A)
	max_val = max(A)
	ans = 0
	for a in A:
		if a > min_val and a < max_val:
			ans += 1
	return ans

def main():
	n = int(input())
	A = list(map(int, input().split()))
	print(solve(A))
main()


n = int(input())
ip = input().split(' ')
mini = int(ip[0])
maxi = int(ip[0])
for x in range(n):
	ip[x] = int(ip[x])
	if ip[x] > maxi:
		maxi = ip[x]
	elif ip[x] < mini:
		mini = ip[x]
res = 0
for x in ip:
	if x != mini and x != maxi:
		res += 1
print(res)


n = int(input())
A = list(map(int, input().split()))
A.sort()
res = 0
for i in range(1, n - 1, 1):
	if n < 3:
		break
	if A[i] > A[0] and A[i] < A[n - 1]:
		res = res + 1
print(res)


n = int(input())
l = [int(x) for x in input().split()]
l.sort()
d = {}
ans = 0
for i in l:
	if i == l[0]:
		d[i] = 1
	elif i == l[-1]:
		d[i] = 1
	elif i in d:
		d[i] += 1
	else:
		d[i] = 1
for i in d:
	if i == l[0] or i == l[-1]:
		continue
	else:
		ans += d[i]
print(ans)


n = int(input())
ls = list(map(int, input().split()))
print(max(0, n - ls.count(max(ls)) - ls.count(min(ls))))


(n, a) = (int(input()), sorted(map(int, input().split())))
r = range(min(a) + 1, max(a))
print(sum((1 for x in a if x in r)))


n = int(input())
l = list(map(int, input().split()))
l.sort()
miN = l[0]
maX = l[-1]
co = 0
for i in l:
	if miN < i < maX:
		co += 1
print(co)


x = int(input())
p = sorted(list(map(int, input().split())))
(mx, mn) = (max(p), min(p))
(n1, n2) = (p.count(mx), p.count(mn))
print(0 if mx == mn else x - n1 - n2)


def solve():
	n = int(input())
	x = sorted([int(i) for i in input().split()])
	(min_, max_) = (x[0], x[-1])
	count = 0
	for i in x:
		if i > min_ and i < max_:
			count += 1
	print(count)
solve()


n = int(input())
a = list(map(int, input().split()))
a.sort()
count = 0
for x in a:
	if a[0] == x or a[-1] == x:
		count += 1
print(n - count)


n = int(input())
d = list(map(int, input().split()))
print(max(0, n - d.count(min(d)) - d.count(max(d))))


n = int(input())
s = list(map(int, input().split()))
a = n - s.count(max(s)) - s.count(min(s))
if a < 0:
	print(0)
else:
	print(a)


from collections import Counter
n = int(input())
l = list(map(int, input().split()))
d = Counter(l)
j = sorted(d.items(), key=lambda x: x[0])
c = 0
for i in range(1, len(j) - 1):
	c += j[i][1]
print(c)


(num, stewards) = (input(), [int(i) for i in input().split()])
mn = min(stewards)
mx = max(stewards)
print(len([i for i in stewards if i > mn and i < mx]))


n = input()
a = list(map(int, input().split()))
ma = max(a)
mi = min(a)
maxs = a.count(ma)
mins = a.count(mi)
res = len(a) - maxs - mins
print(res if res > 0 else 0)


n = int(input())
strength = [int(x) for x in input().split()]
maxStrength = max(strength)
minStrength = min(strength)
res = 0
for i in strength:
	if i != maxStrength and i != minStrength:
		res += 1
print(res)


n = int(input())
inp = list(map(int, input().split()))
from collections import Counter
c = Counter(inp)
if len(c.keys()) <= 2:
	print('0')
else:
	d = list(c.keys())
	d.sort()
	count = 0
	for i in range(1, len(d) - 1):
		count = count + c[d[i]]
	print(count)


n = int(input())
g = [int(x) for x in input().split()]
(h, l) = (max(g), min(g))
ans = 0
for i in range(n):
	if g[i] < h and g[i] > l:
		ans += 1
print(ans)


n = int(input())
(mx, mn) = (-1, 1000000001)
(cx, cn) = (0, 0)
for i in map(int, input().split()):
	if i > mx:
		cx = 0
		mx = i
	if i < mn:
		cn = 0
		mn = i
	if i == mn:
		cn += 1
	if i == mx:
		cx += 1
print(n - cx - cn if not cx + cn == 2 * n else 0)


n = int(input())
a = list(map(int, input().split()))
minv = a[0]
maxv = a[0]
for i in range(1, n):
	minv = min(minv, a[i])
	maxv = max(maxv, a[i])
ans = 0
for i in range(n):
	if a[i] > minv and a[i] < maxv:
		ans += 1
print(ans)


n = int(input())
dict1 = {}
l1 = [int(x) for x in input().split()]
l1.sort()
for i in l1:
	if i in dict1:
		dict1[i] += 1
	else:
		dict1[i] = 1
if len(dict1) < 3:
	print('0')
else:
	print(len(l1) - dict1[l1[0]] - dict1[l1[-1]])


n = int(input())
l = list(map(int, input().split()))
max1 = max(l)
min1 = min(l)
count = 0
for i in range(len(l)):
	if l[i] < max1 and l[i] > min1:
		count += 1
print(count)


def ras(x):
	a = x.count(max(x))
	b = x.count(min(x))
	c = len(x) - a - b
	if c < 0:
		return 0
	return c
n = int(input())
x = [int(i) for i in input().split()]
r = ras(x)
print(r)


num_stewards = int(input())
strength = []
strength = list(map(int, input().split()))
max = strength[0]
min = strength[0]
for i in range(1, num_stewards):
	if strength[i] > max:
		max = strength[i]
	if strength[i] < min:
		min = strength[i]
num = 0
for i in range(0, num_stewards):
	if strength[i] > min and strength[i] < max:
		num = num + 1
print(num)


n = int(input())
a = list(map(int, input().split(' ')))
i = 0
if len(set(a)) > 2:
	x = a.count(min(a))
	y = a.count(max(a))
	print(n - x - y)
else:
	print(0)


n = int(input())
a = list(map(int, input().split()))
c = a.count(max(a)) + a.count(min(a))
if min(a) == max(a):
	print(n - c // 2)
else:
	print(n - c)


n = int(input())
arr = [int(x) for x in input().split()]
M = max(arr)
m = min(arr)
cnt = 0
for i in arr:
	if i > m and i < M:
		cnt += 1
print(cnt)


n = int(input())
l = list(map(int, input().split()))
x = l.count(max(l))
y = l.count(min(l))
s = n - x - y
if s <= 0:
	print(0)
else:
	print(s)


n = int(input())
l = [int(i) for i in input().split()]
if n == 2:
	print(0)
else:
	maximum = max(l)
	minimum = min(l)
	count = 0
	for i in range(len(l)):
		if maximum > l[i] and l[i] > minimum:
			count += 1
	print(count)


nb_steward = int(input())
strengths = [int(x) for x in input().split()]
mins = strengths.count(min(strengths))
maxs = strengths.count(max(strengths))
print(max(0, nb_steward - mins - maxs))


(n, count) = (int(input()), 0)
l = [int(ele) for ele in input().split()]
l.sort()
for i in range(len(l)):
	if l[i] < l[len(l) - 1] and l[i] > l[0]:
		count += 1
print(count)


n = int(input())
l = [int(i) for i in input().split()]
k = sorted(l)
from bisect import bisect_left as bl, bisect_right as br
if n == 1 or n == 2:
	print(0)
else:
	c = 0
	for i in range(n):
		ind = bl(k, l[i])
		ind1 = br(k, l[i])
		c += 0 if ind == 0 or ind1 == n else 1
	print(c)


n = int(input())
stewards = list(map(int, input().split()))[:n]
a = min(stewards)
b = max(stewards)
c = 0
for i in range(len(stewards)):
	if stewards[i] > a and stewards[i] < b:
		c = c + 1
print(c)


n = int(input())
l = list(map(int, input().split()))
l.sort()
cnt = 0
for i in range(len(l)):
	if l[0] < l[i] < l[-1]:
		cnt += 1
print(cnt)


n = int(input())
strengths = [int(s) for s in input().split()]
mx = max(strengths)
mn = min(strengths)
ans = 0
for s in strengths:
	if mn < s < mx:
		ans += 1
print(ans)


n = int(input())
a = list(map(int, input().split()))
c = 0
f = {}
for i in a:
	if i not in f:
		f[i] = 0
	f[i] += 1
l = sorted(list(f.keys()))
for i in l[1:-1]:
	c += f[i]
print(c)


n = int(input())
a = list(map(int, input().split()))
a.sort()
b = [a[0]] + [a[-1]]
for i in range(1, n):
	if a[i] in b:
		b.append(a[i])
	else:
		break
for i in range(n - 2, -1, -1):
	if a[i] in b:
		b.append(a[i])
	else:
		break
print(max(len(a) - len(b), 0))


n = int(input())
j = 0
k = 0
l = list(map(int, input().split()))
maxx = max(l)
minn = min(l)
for i in range(len(l)):
	if l[i] == maxx:
		j += 1
	elif l[i] == minn:
		k += 1
if maxx == minn:
	print(0)
else:
	print(n - j - k)


n = int(input())
a = [int(x) for x in input().split()]
largest = max(a)
smallest = min(a)
total = 0
for item in a:
	if item > smallest and item < largest:
		total += 1
print(total)


n = int(input())
lis = [int(x) for x in input().split()]
lis.sort()
(a, b) = (lis[0], lis[-1])
ans = 0
for i in range(n):
	if lis[i] != a and lis[i] != b:
		ans += 1
print(ans)


input()
l = list(map(int, input().split()))
l = sorted(l)
m = min(l)
M = max(l)
print(len([i for i in l if i > m and i < M]))


x = int(input())
s = sorted(list(map(int, input().split())))
print(max(x - s.count(s[0]) - s.count(s[-1]), 0))


n = input()
s = list(map(int, input().split()))
mx = s.count(max(s))
mn = s.count(min(s))
if len(set(s)) >= 2:
	print(len(s) - (mn + mx))
else:
	print(0)


def steward(n, arr):
	arr.sort()
	count = 0
	for i in range(1, n - 1):
		if arr[0] < arr[i] and arr[n - 1] > arr[i]:
			count += 1
	print(count)
	return
n = int(input())
arr = [int(arr) for arr in input().split()]
steward(n, arr)


n = input()
s = [int(s) for s in input().split()]
result = 0
g = int(len(s) / 2)
big = False
low = False
mx = max(s)
mn = min(s)
for i in s:
	if i > mn:
		big = True
	if i < mx:
		low = True
	if low and big:
		result += 1
		big = False
		low = False
		continue
	big = False
	low = False
print(result)


n = int(input())
l = [int(x) for x in input().split()]
(a, b) = (min(l), max(l))
c = 0
for x in l:
	if a < x < b:
		c += 1
print(c)


string = input()
n = int(string)
stuards = input().split()
for i in range(0, len(stuards)):
	stuards[i] = int(stuards[i])
minimum = min(stuards)
maximum = max(stuards)
if minimum != maximum:
	n = n - stuards.count(minimum)
	n = n - stuards.count(maximum)
	print(n)
else:
	print(0)


n = int(input())
s = input().split()
s = list(map(int, s))
s.sort()
ma = s[n - 1]
mi = s[0]
p = len(s)
for t in s:
	if t == ma or t == mi:
		p -= 1
print(p)


import sys
n = int(input())
a = list(map(int, input().split()))
mn = min(a)
mx = max(a)
ans = 0
for i in range(n):
	if a[i] > mn and a[i] < mx:
		ans += 1
print(ans)


c = 1
cases = 1
while c <= cases:
	n = int(input())
	a = [int(i) for i in input().split()]
	supp = 0
	max_s = max(a)
	min_s = min(a)
	for i in a:
		if i < max_s and i > min_s:
			supp += 1
	print(supp)
	c = c + 1


n = int(input())
line = list(map(int, input().split()))
m1 = min(line)
m2 = max(line)
ans = 0
for i in range(len(line)):
	if line[i] < m2 and line[i] > m1:
		ans += 1
print(ans)


n = int(input())
l = list(map(int, input().split()))
mi = min(l)
ma = max(l)
count = 0
for i in l:
	if i != mi and i != ma:
		count += 1
print(count)


n = int(input(''))
a = [int(x) for x in input('').split()]
minimum = min(a)
maximum = max(a)
ans = len(a)
for i in range(n):
	if a[i] == minimum or a[i] == maximum:
		ans -= 1
print(ans)


n = int(input())
stwd = input().split()
asstd = 0
stwd.sort(key=int)
for item in stwd:
	if int(item) > int(stwd[0]) and int(item) < int(stwd[-1]):
		asstd += 1
print(asstd)


n = int(input())
a = list(map(int, input().split()))
(m1, m2) = (a.count(min(a)), a.count(max(a)))
z = n - m1 - m2
if m1 + m2 == 2 * n:
	print(0)
else:
	print(z)


n = int(input())
a = sorted([int(i) for i in input().split()])
minimum = min(a)
maximum = max(a)
c = 0
for i in a:
	if i > minimum and i < maximum:
		c += 1
print(c)


class CodeforcesTask768ASolution:

	def __init__(self):
		self.result = ''
		self.stewards = []

	def read_input(self):
		input()
		self.stewards = [int(x) for x in input().split(' ')]

	def process_task(self):
		self.stewards.sort()
		start = 0
		for s in self.stewards:
			if s > self.stewards[0]:
				break
			else:
				start += 1
		stop = 0
		for s in self.stewards[::-1]:
			if s < self.stewards[-1]:
				break
			else:
				stop += 1
		result = len(self.stewards) - start - stop
		if result < 0:
			result = 0
		self.result = str(result)

	def get_result(self):
		return self.result
Solution = CodeforcesTask768ASolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


n = int(input())
a = sorted(map(int, input().split()))
z = a.count(a[0])
x = a.count(a[-1])
if a[0] == a[-1]:
	print(0)
else:
	print(len(a) - z - x)


noOfStewards = int(input())
strengthOfEachStewards = [int(x) for x in input().split(' ')]
noOfStewardsJonSnowWillSupport = 0
minStrength = min(strengthOfEachStewards)
maxStrength = max(strengthOfEachStewards)
for strength in strengthOfEachStewards:
	if minStrength < strength < maxStrength:
		noOfStewardsJonSnowWillSupport += 1
print(noOfStewardsJonSnowWillSupport)


n = int(input())
a = list(map(int, input().split()))
from collections import Counter as cc
l = cc(a).items()
l = sorted(l)
if len(l) <= 2:
	print(0)
else:
	s = 0
	for i in range(1, len(l) - 1):
		s += l[i][1]
	print(s)


n = eval(input())
a = [i for i in map(int, input().split())]
s = 0
a = sorted(a)
k1 = min(a)
k2 = max(a)
for i in range(1, n - 1):
	if a[i] > k1 and a[i] < k2:
		s += 1
print(s)


n = int(input())
stewards = list(map(int, input().split()))
stewards = sorted(stewards)
if n == 1:
	print(0)
elif stewards[0] == stewards[-1]:
	print(0)
else:
	count = len(stewards) - stewards.count(stewards[0]) - stewards.count(stewards[-1])
	print(count)


stewards_num = input()
stewards = list(map(int, input().split(' ')))
stewards_who_will_john_snow_support = 0
stewards.sort()
min_steward_strength = min(stewards)
max_steward_strength = max(stewards)
for steward in stewards:
	if steward > min_steward_strength and steward < max_steward_strength:
		stewards_who_will_john_snow_support += 1
print(stewards_who_will_john_snow_support)


import sys

def debug(x, table):
	for (name, val) in table.items():
		if x is val:
			print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
			return None

def solve():
	n = int(input())
	As = [int(i) for i in input().split()]
	As.sort()
	ans = 0
	if As[0] == As[-1]:
		print(0)
		return None
	ans += As.count(As[0])
	ans += As.count(As[-1])
	ans = n - ans
	print(ans)
solve()


n = int(input())
arr = [int(x) for x in input().split()]
(ans, mi, ma) = (0, min(arr), max(arr))
for x in arr:
	if not (x == mi or x == ma):
		ans += 1
print(ans)


n = int(input())
ara = list((int(i) for i in input().split()))
ara.sort()
if n <= 2:
	print(0)
else:
	fst = ara[0]
	st = None
	lt = None
	for i in range(1, n):
		if ara[i] != fst:
			st = i
			break
	fst = ara[n - 1]
	for i in range(n - 1, -1, -1):
		if ara[i] != fst:
			lt = i
			break
	if st is None or lt is None:
		print(0)
	else:
		print(1 + (lt - st))


n = int(input())
l = list(map(int, input().split()))
Min = min(l)
Max = max(l)
count = 0
for i in l:
	if i > Min and i < Max:
		count += 1
print(count)


n = int(input())
inp = input().split()
arr = []
for i in range(len(inp)):
	arr.append(int(inp[i]))
arr.sort()
min1 = arr[0]
max1 = arr[len(arr) - 1]
count = 0
for i in range(1, n):
	if arr[i] > min1 and arr[i] < max1:
		count += 1
print(count)


number_of_stewards = int(input())
stewards = list(map(int, input().split()))
maxmum = max(stewards)
minmum = min(stewards)
number_of_support = 0
i = 0
while i < len(stewards):
	if stewards[i] > minmum and stewards[i] < maxmum:
		number_of_support += 1
	i += 1
print(number_of_support)


num_stewards = int(input())
strength = list(map(int, input().split()))
strength.sort()
support = 0
low = strength[0]
high = strength[num_stewards - 1]
for i in range(0, num_stewards):
	if strength[i] != low and strength[i] != high:
		support = support + 1
print(support)


n = int(input())
a = list(map(int, input().split()))
mx = max(a)
mi = min(a)
cnt = 0
for i in a:
	if i < mx and i > mi:
		cnt += 1
print(cnt)


n = int(input())
a = [int(x) for x in input().split()]
mini = min(a)
maxi = max(a)
c = 0
for x in a:
	if x != mini and x != maxi:
		c += 1
print(c)


from sys import stdin
n = int(stdin.readline())
a = list(map(int, stdin.readline().split()))
mns = a.count(min(a))
mxs = a.count(max(a))
res = n - mns - mxs
if res < 0:
	res = 0
print(res)


import sys
n = sys.stdin.readline()
n = int(n)
if n == 1 or n == 2:
	print(0)
	exit()
m = sys.stdin.readline()
num = m.split(' ')
for i in range(n):
	num[i] = int(num[i])
num.sort()
ans = 0
a = max(num)
b = min(num)
for i in range(n):
	if num[i] > b and num[i] < a:
		ans = ans + 1
print(ans)


n = int(input())
a = [int(x) for x in input().split()]
themin = min(a)
themax = max(a)
answer = 0
for x in a:
	if x > themin and x < themax:
		answer += 1
print(answer)


n = int(input())
m = list(map(int, input().split()))
m.sort()
total = 0
mins = m[0]
maxs = m[-1]
for i in range(1, n - 1):
	if m[i] > mins and m[i] < maxs:
		total += 1
print(total)


n = int(input().strip())
stewards = list(map(int, input().strip().split()))
most = max(stewards)
least = min(stewards)
print(len([x for x in stewards if least < x < most]))


n = int(input())
a = [int(x) for x in input().split()]
a.sort()
c = 0
for i in range(len(a)):
	if a[i] > a[0] and a[i] < a[-1]:
		c += 1
print(c)


n = int(input())
a = [int(x) for x in input().split(' ')[:n]]
print(max(0, n - a.count(min(a)) - a.count(max(a))))


import sys

def main(arr):
	if not arr:
		print(0)
		return
	arr.sort()
	smallest_yet = [arr[0]]
	for i in range(1, len(arr)):
		smallest_yet.append(min(smallest_yet[-1], arr[i]))
	largest_yet = [arr[-1]]
	for i in range(len(arr) - 2, -1, -1):
		largest_yet.append(max(arr[-1], arr[i]))
	largest_yet.reverse()
	support = 0
	for i in range(1, len(arr) - 1):
		if largest_yet[i + 1] > arr[i] and smallest_yet[i - 1] < arr[i]:
			support += 1
	print(support)
for (e, line) in enumerate(sys.stdin.readlines()):
	if e == 0:
		continue
	else:
		arr = list(map(int, line.strip().split()))
main(arr)


import sys
n = int(input())
l = list(map(int, input().split()))
min = sys.maxsize
max = -sys.maxsize - 1
c = 0
for i in l:
	if i > max:
		max = i
	if i < min:
		min = i
for i in l:
	if i > min and i < max:
		c += 1
print(c)


T = int(input())
p = list(map(int, input().split()))
c = max(p)
d = min(p)
count = 0
for i in range(len(p)):
	if p[i] > d and p[i] < c:
		count += 1
print(count)


n = int(input())
l = list(map(int, input().split()))
l.sort()
mi = l[0]
ma = l[-1]
c = 0
for i in range(1, n):
	if l[i] > mi and l[i] < ma:
		c = c + 1
print(c)


n = int(input())
str1 = input().split()
for x in range(len(str1)):
	str1[x] = int(str1[x])
mini = min(str1)
maxi = max(str1)
ct = 0
for i in str1:
	if i > mini and i < maxi:
		ct += 1
print(ct)


n = int(input())
a = sorted(map(int, input().split(' ')))
result = sum([1 if i > a[0] and i < a[-1] else 0 for i in a])
print(result)


import math
from collections import defaultdict
ml = lambda : map(int, input().split())
ll = lambda : list(map(int, input().split()))
ii = lambda : int(input())
ip = lambda : input()
t = ii()
a = ll()
mn = min(a)
mx = max(a)
ans = 0
for i in a:
	if i != mn and i != mx:
		ans += 1
print(ans)


n = int(input())
li = list(map(int, input().split()))
li.sort()
x = len(li) - li.count(li[0]) - li.count(li[-1])
if x >= 0:
	print(x)
else:
	print(0)


n = input()
l = list(map(int, input().split()))
l.sort()
(t1, t2) = (l[0], l[-1])
while l and l[0] == t1:
	del l[0]
while l and l[-1] == t2:
	del l[-1]
print(len(l))


from sys import stdin

def main():
	n = int(input())
	A = list(map(int, stdin.readline().split()))
	A.sort()
	if A[0] != A[-1]:
		print(n - A.count(A[0]) - A.count(A[-1]))
	else:
		print(0)
main()


n = int(input())
a = [*map(int, input().split())]
print(max(0, n - a.count(max(a)) - a.count(min(a))))


import sys
input = sys.stdin.readline
n = int(input().strip())
a = list(map(int, input().strip().split()))
a.sort()
ans = 0
for i in range(1, n - 1):
	if a[i] > a[0] and a[i] < a[-1]:
		ans += 1
print(ans)


n = int(input())
stewards = list(map(int, input().split()))
stewards.sort()
cnt = 0
j = 1
for i in range(1, n - 1, 1):
	if stewards[n - 1] > stewards[i] > stewards[0]:
		cnt += 1
print(cnt)


n = int(input())
l = list([int(x) for x in input().split()])
if n <= 2:
	print(0)
else:
	a = min(l)
	b = max(l)
	l = [x for x in l if x > a and x < b]
	print(len(l))


__author__ = 'Ryabchun Vladimir'
n = int(input())
stuards = list(map(int, input().split()))
stset = set(stuards)
if n == 1 or len(stset) == 1 or n == 2:
	print(0)
else:
	min = stuards.count(min(stuards))
	max = stuards.count(max(stuards))
	ans = n - min - max
	print(ans)


n = int(input())
a = list(map(int, input().split()))
(p1, p2, cnt) = (min(a), max(a), 0)
for i in a:
	if p1 < i < p2:
		cnt += 1
print(cnt)


def main():
	n = int(input())
	strengths = [int(_) for _ in input().split()]
	strengths.sort()
	min_strength = strengths[0]
	max_strength = strengths[n - 1]
	if min_strength == max_strength:
		print(0)
	else:
		n -= strengths.count(min_strength) + strengths.count(max_strength)
		print(n)
main()


n = int(input())
l = list(map(int, input().split()))
m1 = max(l)
m2 = min(l)
c = 0
c2 = 0
for i in range(n):
	if l[i] == m1:
		c = c + 1
	if l[i] == m2:
		c2 = c2 + 1
if m1 == m2:
	print(0)
else:
	print(n - c2 - c)


n = int(input())
a = list(map(int, input().strip().split()))
runmin = a[0]
runmax = a[0]
for i in range(n):
	if a[i] <= runmin:
		runmin = a[i]
	if a[i] >= runmax:
		runmax = a[i]
temp = 0
for i in range(n):
	if a[i] > runmin and a[i] < runmax:
		temp = temp + 1
print(temp)


n = int(input())
a = [int(x) for x in input().split()]
if n <= 2:
	print(0)
else:
	a.sort()
	p = a[0]
	b = [[p, 1]]
	for i in range(1, n):
		if a[i] == p:
			b[-1][1] += 1
		else:
			p = a[i]
			b.append([p, 1])
	st = 0
	for i in range(1, len(b) - 1):
		if b[i - 1][0] < b[i][0] < b[i + 1][0]:
			st += b[i][1]
	print(st)


n = int(input())
a = list(map(int, input().split()))
a.sort()
d = a.count(max(a))
e = a.count(min(a))
c = 0
if len(a) < 3:
	c = 0
else:
	c = n - d - e
	if c < 0:
		c = 0
print(c)


n = int(input())
a = list(map(int, input().split()))
a.sort()
b = a.count(a[0]) + a.count(a[-1])
print(max(0, n - b))


a = int(input())
i = 0
b = list(map(int, input().split()))
b.sort()
max_b = b[a - 1]
min_b = b[0]
if max_b == min_b:
	c = a - b.count(max_b)
else:
	c = a - b.count(max_b) - b.count(min_b)
print(c)


num_stewards = int(input())
stewards = [int(x) for x in input().split(' ')]
maxi = max(stewards)
mini = min(stewards)
print(sum((1 if maxi > x > mini else 0 for x in stewards)))


n = int(input())
a = list(map(int, input().split()))
mini = min(a)
maxi = max(a)
total = len(a)
for i in range(len(a)):
	if a[i] == mini or a[i] == maxi:
		total -= 1
print(total)


n = int(input())
arr = list(map(int, input().split()))
if len(set(arr)) < 3:
	print(0)
	exit(0)
print(n - arr.count(max(arr)) - arr.count(min(arr)))


n = int(input())
ste = list(map(int, input().split()))
counter = 0
mx = max(ste)
mn = min(ste)
for x in ste:
	if x > mn and x < mx:
		counter += 1
print(counter)


n = int(input())
A = list(map(int, input().split()))
s = 0
A.sort()
for j in range(1, n - 1):
	if A[j] > A[0] and A[j] < A[-1]:
		s += 1
print(s)


n = int(input())
a = [int(i) for i in input().split()]
d = {}
ans = 0
for i in a:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
a = list(set(a))
a.sort()
if len(a) < 3:
	print(ans)
else:
	for i in range(1, len(a) - 1):
		ans += d[a[i]]
	print(ans)


x = int(input())
d = [int(d) for d in input().split()]
count = 0
d1 = min(d)
d2 = max(d)
for i in d:
	if i > d1 and i < d2:
		count += 1
print(count)


inp = int(input())
l = sorted(list(map(int, input().split())))
sum = 0
for num in l[1:inp - 1]:
	if num != l[0] and num != l[-1]:
		sum += 1
print(sum)


n = int(input())
m = list(map(int, input().split()))
a = set(m)
if len(a) <= 2:
	print(0)
else:
	m.sort()
	print(n - m.count(m[0]) - m.count(m[-1]))


n = int(input())
s = input().split()
s = list(map(int, s))
jon = sorted(s)
mx = jon[0]
mn = jon[n - 1]
cmx = 0
cmn = 0
for i in s:
	if i == mx:
		cmx += 1
	if i == mn:
		cmn += 1
if mx == mn:
	print(0)
else:
	print(n - cmn - cmx)


n = int(input())
a = sorted(map(int, input().split()))
(l, r) = (0, n - 1)
while r >= l and (a[l] == a[0] or a[r] == a[n - 1]):
	if a[l] == a[0]:
		l += 1
	if a[r] == a[n - 1]:
		r -= 1
print(r - l + 1 if r >= l else 0)


n = int(input())
arr = [int(x) for x in input().split()]
arr = sorted(arr)
sol = n - arr.count(arr[0]) - arr.count(arr[n - 1])
if sol < 0:
	sol = 0
print(sol)


n = int(input())
lt = list(input().split())
for i in range(n):
	lt[i] = int(lt[i])
lt.sort()
k = lt[0]
i = 0
while i < n and lt[i] == k:
	i += 1
j = len(lt) - 1
k = lt[j]
while j > -1 and lt[j] == k:
	j -= 1
print(len(lt[i:j + 1]))


from sys import stdin, stdout
import bisect
import math

def st():
	return list(stdin.readline().strip())

def inp():
	return int(stdin.readline())

def li():
	return list(map(int, stdin.readline().split()))

def mp():
	return map(int, stdin.readline().split())

def pr(n):
	stdout.write(str(n) + '\n')

def soe(limit):
	l = [1] * (limit + 1)
	prime = []
	for i in range(2, limit + 1):
		if l[i]:
			for j in range(i * i, limit + 1, i):
				l[j] = 0
	for i in range(2, limit + 1):
		if l[i]:
			prime.append(i)
	return prime

def segsoe(low, high):
	limit = int(high ** 0.5) + 1
	prime = soe(limit)
	n = high - low + 1
	l = [0] * (n + 1)
	for i in range(len(prime)):
		lowlimit = low // prime[i] * prime[i]
		if lowlimit < low:
			lowlimit += prime[i]
		if lowlimit == prime[i]:
			lowlimit += prime[i]
		for j in range(lowlimit, high + 1, prime[i]):
			l[j - low] = 1
	for i in range(low, high + 1):
		if not l[i - low]:
			if i != 1:
				print(i)

def power(a, n):
	r = 1
	while n:
		if n & 1:
			r = r * a
		a *= a
		n = n >> 1
	return r

def solve():
	n = inp()
	l = li()
	d = {}
	l.sort()
	for i in l:
		d[i] = d.get(i, 0) + 1
	if l[0] != l[-1]:
		print(n - d[l[0]] - d[l[-1]])
	else:
		print(0)
for _ in range(1):
	solve()


n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = 0
for i in a:
	if a[0] < i and a[-1] > i:
		ans += 1
print(ans)


def jon(arr):
	cont = 0
	arr.sort()
	for i in range(len(arr) - 1):
		if arr[0] == arr[i]:
			continue
		elif arr[-1] == arr[i]:
			continue
		else:
			cont = cont + 1
	return cont
n = int(input())
arr1 = list(map(int, input().strip().split()))
print(jon(arr1))


n = int(input())
arr = list(map(int, input().split()))
if len(arr) <= 2:
	print(0)
else:
	arr.sort()
	count = 0
	for i in range(1, n - 1):
		if arr[0] < arr[i] and arr[-1] > arr[i]:
			count += 1
	print(count)


n = int(input())
s = [int(i) for i in input().split()]
mx = max(s)
mn = min(s)
an = n
for i in range(n):
	if s[i] == mx or s[i] == mn:
		an -= 1
print(an)


n = int(input())
data = {}
l = list(map(int, input().split()))
for x in l:
	if x not in data:
		data[x] = 0
	data[x] = data[x] + 1
keys = list(data.keys())
keys.sort()
ans = 0
for i in range(1, len(keys) - 1):
	ans = ans + data[keys[i]]
print(ans)


n = int(input())
l = list(map(int, input().split()))
p = min(l)
q = max(l)
s = []
for i in l:
	if i != p and i != q:
		s.append(i)
print(len(s))


games = int(input())
stewards = [int(i) for i in str(input()).split(' ')]
mini = stewards[0]
maxi = stewards[0]
countMin = 0
countMax = 0
for steward in stewards:
	if steward < mini:
		countMin = 1
		mini = steward
	elif steward == mini:
		countMin += 1
	if steward > maxi:
		countMax = 1
		maxi = steward
	elif steward == maxi:
		countMax += 1
if mini != maxi:
	print(len(stewards) - countMin - countMax)
else:
	print(len(stewards) - countMin)


_ = input()
arr = list(map(int, input().split()))
if len(arr) <= 2:
	print(0)
else:
	arr.sort()
	sm = arr[0]
	lg = arr[len(arr) - 1]
	count = 0
	for i in arr:
		if i != sm and i != lg:
			count += 1
	print(count)


d = int(input())
a = sorted([int(_) for _ in input().split()])
print(max(d - a.count(max(a)) - a.count(min(a)), 0))


length = int(input())
stewards = [int(item) for item in input().split(' ')]
stewards.sort()
big = stewards[length - 1]
small = stewards[0]
result = 0
for x in stewards:
	if small < x < big:
		result += 1
print(result)


n = int(input())
a = list(sorted(map(int, input().split())))
count = 0
for i in a:
	if i == a[0] or i == a[len(a) - 1]:
		count += 1
print(len(a) - count)


import bisect
t = int(input())
listt = list(map(int, input().split()))
listt.sort()
first = listt[0]
last = listt[-1]
if first != last:
	t1 = bisect.bisect_right(listt, first)
	t2 = bisect.bisect_left(listt, last)
	print(t2 - t1)
else:
	print(0)


import sys

def read_input():
	for (idx, line) in enumerate(sys.stdin):
		if idx == 0:
			continue
		elif idx == 1:
			return [int(x) for x in line.split(' ')]

def process(x):
	l = min(x)
	r = max(x)
	return sum((t > l and t < r for t in x))

def print_output(res):
	print(res)
print_output(process(read_input()))


n = int(input())
arr = list(map(int, input().split()))
arr = sorted(arr)
count = 0
for i in range(n):
	if arr[i] > arr[0] and arr[i] < arr[n - 1]:
		count += 1
print(count)


def main():
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	cnt = 0
	index = 0
	while index < n - 1 and a[index] == a[index + 1]:
		index += 1
		cnt += 1
	index = n - 1
	while index > 0 and a[index] == a[index - 1]:
		index -= 1
		cnt += 1
	print(max(n - 2 - cnt, 0))
main()


n = int(input())
a = [int(z) for z in input().split()]
a.sort()
i = 0
while i < n and a[i] == a[0]:
	i += 1
j = n - 1
while j >= 0 and a[j] == a[-1]:
	j -= 1
print(max(0, j - i + 1))


n = int(input())
l = [int(i) for i in input().split()]
mn = min(l)
mx = max(l)
ans = 0
for i in range(n):
	if l[i] > mn and l[i] < mx:
		ans += 1
print(ans)


n = int(input())
arr = [int(x) for x in input().split()]
arr.sort()
min_max_count = arr.count(arr[0]) + arr.count(arr[-1])
print(max(0, len(arr) - min_max_count))


n = int(input())
l = sorted(list(map(int, input().split())))
ans = 0
for i in range(len(l)):
	if l[0] < l[i] and l[-1] > l[i]:
		ans += 1
print(ans)


stuards = int(input())
stuardsPower = [int(x) for x in input().split(' ')]
minn = min(stuardsPower)
maxx = max(stuardsPower)
helped = 0
for stuard in stuardsPower:
	if stuard < maxx and stuard > minn:
		helped += 1
print(helped)


n = int(input())
arr = list(map(int, input().split()))
arr.sort()
print(max(0, n - arr.count(arr[0]) - arr.count(arr[n - 1])))


counter = 0
x = int(input())
z = map(int, input().split())
z = list(z)
if 1 <= x <= 10 ** 5 and 0 <= min(z) and (max(z) <= 10 ** 9):
	z.sort()
	for c in range(len(z)):
		if z[0] < z[c] < z[-1]:
			counter = counter + 1
	print(counter)


n = int(input())
l = [int(x) for x in input().split()]
l.sort()
a = 0
b = 0
for i in range(n):
	if l[i] == l[0]:
		a += 1
	else:
		break
for i in range(n - 1, -1, -1):
	if l[i] == l[n - 1] and l[n - 1] != l[0]:
		b += 1
	else:
		break
if n == 1:
	print('0')
else:
	print(n - a - b)


n = int(input())
a = [int(x) for x in input().split(' ')]
m = min(a)
M = max(a)
res = n
res -= len([x for x in a if x == m or x == M])
print(res)


n = int(input())
l = [int(x) for x in input().split()]
mi = min(l)
ma = max(l)
leng = len(l)
for i in l:
	if i == mi or i == ma:
		leng -= 1
print(leng)


n = int(input())
strength = list(map(int, input().split()))
(min, max, k, j) = (1, 1, 1, 1)
strength.sort()
if strength[0] != strength[-1]:
	while strength[j] == strength[j - 1]:
		min += 1
		j += 1
strength.sort(reverse=True)
if strength[0] != strength[-1]:
	while strength[k] == strength[k - 1]:
		max += 1
		k += 1
if n > 2 and strength[0] != strength[-1]:
	print(n - min - max)
else:
	print(0)


n = int(input())
lst = [eval(i) for i in input().split()]
lst.sort()
kol = n - lst.count(lst[0]) - lst.count(lst[n - 1])
if kol < 0:
	print(0)
else:
	print(kol)


N = int(input())
L = list(map(int, input().split()))
mn = min(L)
mx = max(L)
sol = N - L.count(mn) - L.count(mx)
print(max(0, sol))


number = int(input())
strenght = list(map(int, input().split()))
strenght.sort()
if strenght[0] != strenght[-1]:
	borders = strenght.count(strenght[0]) + strenght.count(strenght[-1])
else:
	borders = strenght.count(strenght[0])
print(number - borders)


n = int(input())
arr = [int(x) for x in input().split()]
count = 0
(x, y) = (min(arr), max(arr))
for i in range(0, len(arr)):
	if arr[i] != x and arr[i] != y:
		count += 1
print(count)


num = int(input())
arr = [0] * num
arr = input().split()
for i in range(num):
	arr[i] = int(arr[i])
arr.sort()
mini = arr[0]
maxi = arr[num - 1]
count = 0
for i in range(num):
	if arr[i] == mini:
		count += 1
	if arr[i] == maxi:
		count += 1
if 2 * num == count:
	print(0)
elif num == 1:
	print(0)
elif num == 2:
	print(0)
else:
	print(num - count)


import sys
from os import path
if path.exists('in.txt'):
	sys.stdin = open('in.txt', 'r')
	sys.stdout = open('out.txt', 'w')

def ri():
	return int(input())

def ria():
	return [int(x) for x in input().split()]
n = ri()
lihys = ria()
smallest = 1000000000.0 + 1
largest = 0
for x in lihys:
	smallest = min(smallest, x)
	largest = max(largest, x)
count = 0
for x in lihys:
	if x != smallest and x != largest:
		count += 1
print(count)


n = int(input())
a = list(map(int, input().split()))
mx = max(a)
mn = min(a)
print(len([s for s in a if mn < s < mx]))


n = int(input())
a = sorted(map(int, input().split()))
print(max(0, len(a) - a.count(a[0]) - a.count(a[-1])))


def main():
	n = int(input())
	ls = list(map(int, input().split()))
	m = min(ls)
	maxi = max(ls)
	c1 = ls.count(m)
	c2 = ls.count(maxi)
	if len(ls) >= c1 + c2:
		print(len(ls) - (c1 + c2))
	else:
		print(0)
main()


n = int(input())
a = list(map(int, input().rstrip().split()))
print(max(0, n - a.count(max(a)) - a.count(min(a))))


n = int(input())
A = [int(_) for _ in input().split()]
B = sorted(A)
(x, y) = (A.count(B[0]), A.count(B[-1]))
print(max(0, len(A) - x - y))


def main(data_raw):
	answer = len(data_raw)
	sort_data = sorted(data_raw)
	for i in range(len(sort_data)):
		if sort_data[i] == sort_data[0]:
			answer -= 1
		elif sort_data[i] == sort_data[len(sort_data) - 1]:
			answer -= 1
	return answer
line = int(input())
data = []
lines = input()
data = [int(n) for n in lines.split()]
print(main(data))


n = int(input())
m = list(map(int, input().split()))[:n]
m.sort()
if m.count(m[0]) == n or m.count(m[-1]) == n - 1:
	s = 0
elif m.count(m[-1]) == n or m.count(m[0]) == n - 1:
	s = 0
else:
	d = m.count(m[0])
	f = m.count(m[-1])
	s = n - d - f
print(s)


n = int(input())
a = list(map(int, input().split()))
m = a.count(max(a))
n = a.count(min(a))
if len(a) - m - n < 0:
	print(0)
else:
	print(len(a) - m - n)


def solve():
	input()
	d = [int(i) for i in input().split()]
	m = min(d)
	k = max(d)
	s = 0
	for i in d:
		if m < i < k:
			s += 1
	print(s)
solve()


a = int(input())
b = list(map(int, input().split()))
mn = min(b)
mx = max(b)
c = 0
for i in b:
	if i > mn and i < mx:
		c += 1
print(c)


x = input()
lst = list(map(int, input().split()))
greatest = max(lst)
smallest = min(lst)
count = 0
for i in lst:
	if smallest < i < greatest:
		count += 1
print(count)


n = int(input())
arr = [int(x) for x in input().split()]
mx = max(arr)
mn = min(arr)
count = 0
for e in arr:
	if e > mn and e < mx:
		count += 1
print(count)


n = int(input())
a = list(map(int, input().split()))
if len(set(a)) == 1:
	print(0)
else:
	print(len(a) - a.count(min(a)) - a.count(max(a)))


n = input()
stewards = list(map(int, input().split()))
counter = 0
(minimum, maximum) = (min(stewards), max(stewards))
for steward in stewards:
	if steward > minimum and steward < maximum:
		counter += 1
print(counter)


n = (int(x) for x in input().split())
a = [int(x) for x in input().split()]
a.sort()
l = len(a)
p = 0
q = 0
for i in range(1, l):
	if a[i - 1] < a[i]:
		p = i
		break
for i in range(l - 1, 0, -1):
	if a[i] > a[i - 1]:
		q = i
		break
print(q - p)


n = int(input())
a = list(map(int, input().split()))
minim = min(a)
maxim = max(a)
c_1 = 0
c_2 = 0
for i in range(n):
	if a[i] == minim:
		c_1 += 1
	if a[i] == maxim:
		c_2 += 1
if minim == maxim:
	print(0)
else:
	print(n - c_1 - c_2)


t = int(input())
a = list(map(int, input().strip().split(' ')))
a.sort()
c = 1
d = 1
if t == 1:
	print(0)
else:
	for i in range(t - 1):
		if a[i] == a[i + 1]:
			c += 1
		else:
			break
	for i in range(t - 1, 0, -1):
		if a[i] == a[i - 1]:
			d += 1
		else:
			break
	if len(list(set(a))) == 1:
		print(len(a) - c)
	else:
		print(len(a) - c - d)


n = int(input())
l = list(map(int, input().split()))
c1 = c2 = 0
mn = min(l)
mx = max(l)
for i in l:
	if i == mn:
		c1 += 1
	if i == mx:
		c2 += 1
if mn == mx:
	print('0')
else:
	print(n - c1 - c2)


n = int(input().strip())
data = [int(x) for x in input().strip().split(' ')]
t = 0
(mn, mx) = (data[0], data[0])
for x in data:
	mn = min(x, mn)
	mx = max(x, mx)
for x in data:
	if x > mn and x < mx:
		t += 1
print(t)


n = int(input())
a = list(map(int, input().split()))
a.sort()
x = max(a)
y = min(a)
count = 0
for i in range(n - 1):
	if a[i] > y and a[i] < x:
		count += 1
print(count)


N = int(input())
stewards = [int(x) for x in input().split()]
stewards.sort()
print(len(stewards[stewards.count(min(stewards)):N - stewards.count(max(stewards))]))


def inp():
	return map(int, input().split())

def arr_inp():
	return [int(x) for x in input().split()]

def print_arr(arr):
	print(*arr, sep=' ')
n = int(input())
a = arr_inp()
a.sort()
(min_c, max_c) = (a.count(a[0]), a.count(a[-1]))
sum = max_c + min_c
if n == 1 or n == min_c:
	print(0)
else:
	print(n - sum)


n = int(input())
s = [int(x) for x in str.split(input())]

class BSTN:

	def __init__(self, x):
		self.Left = None
		self.Right = None
		self.Content = x
		self.Count = 1

	def add(self, x):
		if self.Content == x:
			self.Count += 1
		elif self.Content > x:
			if self.Left == None:
				self.Left = BSTN(x)
			else:
				self.Left.add(x)
		elif self.Right == None:
			self.Right = BSTN(x)
		else:
			self.Right.add(x)

	def MinCount(self):
		if self.Left == None:
			return self.Count
		else:
			return self.Left.MinCount()

	def MaxCount(self):
		if self.Right == None:
			return self.Count
		else:
			return self.Right.MinCount()

class BSTN2:

	def __init__(self, lx, lc, mc, rx, rc):
		self.LCount = lc
		self.LKey = lx
		self.MCount = mc
		self.RCount = rc
		self.RKey = rx

	def add(self, x):
		if self.LKey < x < self.RKey:
			self.MCount += 1
		elif self.LKey == self.RKey:
			if x > self.RKey:
				self.RKey = x
				self.RCount = 1
			elif x < self.LKey:
				self.LKey = x
				self.LCount = 1
			else:
				self.LCount += 1
				self.RCount += 1
		elif x > self.RKey:
			self.MCount += self.RCount
			self.RKey = x
			self.RCount = 1
		elif x < self.LKey:
			self.MCount += self.LCount
			self.LKey = x
			self.LCount = 1
		elif x == self.RKey:
			self.RCount += 1
		elif x == self.LKey:
			self.LCount += 1
r = BSTN2(s[0], 1, 0, s[0], 1)
for i in range(1, n):
	r.add(s[i])
print(max(0, r.MCount))


n = int(input())
a = [int(x) for x in input().split()]
cum = 0
(c, b) = (min(a), max(a))
for i in range(n):
	if c < a[i] < b:
		cum += 1
print(cum)


n = int(input())
li = list(map(int, input().split()))
li.sort()
count = 0
for i in range(len(li)):
	if li[i] > li[0] and li[i] < li[n - 1]:
		count += 1
print(count)


input()
mass = sorted(map(int, input().split()))
k = 0
for i in mass:
	if i > mass[0] and i < mass[-1]:
		k += 1
print(k)


n = int(input())
a = sorted(map(int, input().split()))
ans = n - a.count(min(a)) - a.count(max(a))
if len(set(a)) == 1:
	ans = 0
print(ans)


n = int(input())
m = list(map(int, input().split()))
r = []
if len(m) < 3:
	result = 0
m = sorted(m)
min_m = min(m)
max_m = max(m)
for i in range(len(m)):
	if m[i] != min_m and m[i] != max_m:
		r.append(m[i])
result = len(r)
print(result)


import sys
from collections import Counter
from math import factorial
input = sys.stdin
output = sys.stdout
combinations_dynamic = dict()

def combinations(n, k):
	if k > n - k:
		k = n - k
	if k < 0:
		return 0
	if n < 1:
		return 0
	if k == 0:
		return 1
	if k == 1:
		return n
	question = tuple((n, k))
	if question not in combinations_dynamic:
		combinations_dynamic[question] = combinations(n - 1, k - 1) + combinations(n - 1, k)
	return combinations_dynamic[question]

def read_int():
	return [int(x) for x in input.readline().rstrip().split()]
[n] = read_int()
mas = read_int()
will_not = {min(mas), max(mas)}
will = [1 for x in mas if x not in will_not]
answer = sum(will)
output.write('%d\n' % answer)


i = input()
alpha = list(map(int, input().split()))
alpha = sorted(alpha)
count = 0
for val in range(1, len(alpha) - 1):
	if alpha[val] > alpha[0] and alpha[val] < alpha[len(alpha) - 1]:
		count += 1
print(count)


n = int(input())
f = list(map(int, input().split()))
df = min(f)
t = max(f)
df = f.count(df)
t = f.count(t)
n = n - (df + t)
print(max(0, n))


from bisect import bisect_left, bisect_right
n = int(input())
a = sorted(list(map(int, input().split())))
ln1 = bisect_right(a, a[0])
ln2 = bisect_left(a, a[-1])
print(ln2 - ln1) if a[0] != a[-1] else print(0)


N = int(input())
A = list(map(int, input().split()))
mina = min(A)
maxa = max(A)
ans = 0
for a in A:
	if a != mina and a != maxa:
		ans += 1
print(ans)


garbage = int(input())
l = list(map(int, input().rstrip().split(' ')))
l.sort()
if len(l) < 3:
	print(0)
else:
	mi = min(l)
	ma = max(l)
	l = list(filter(mi.__ne__, l))
	l = list(filter(ma.__ne__, l))
	print(len(l))


n = int(input())
arr = list(map(int, input().strip().split()))[:n]
arr.sort()
n = 0
x = arr[0]
y = arr[len(arr) - 1]
for item in arr:
	if item == x or item == y:
		n += 1
print(len(arr) - n)


n = int(input())
c = 0
l = list(map(int, input().split()))
(a, b) = (min(l), max(l))
for i in l:
	c += int(a < i < b)
print(c)


n = int(input())
a = list(map(int, input().split()))
a.sort()
c = 0
for i in range(n):
	if a[i] > a[0] and a[i] < a[n - 1]:
		c = c + 1
print(c)


n = int(input())
s = list(map(int, input().split()))
c = 0
x = max(s)
y = min(s)
if n <= 2:
	print('0')
else:
	for i in range(n):
		if (s[i] < x) & (s[i] > y):
			c += 1
	print(c)


from sys import stdin

def get_ints():
	return list(map(int, stdin.readline().strip().split()))
n = int(input())
arr = get_ints()
arr = sorted(arr)
ans = 0
if len(set(arr)) == 1:
	print(0)
	exit()
print(n - (arr.count(arr[0]) + arr.count(arr[-1])))


n = int(input())
a = [int(i) for i in input().split()]
a.sort()
(x, y, count) = (a[0], a[n - 1], 0)
for i in a:
	if i > x and i < y:
		count += 1
print(count)


n = int(input())
L = list(map(int, input().split(' ')))
L = sorted(L)
res = 0
mini = L[0]
maxi = L[len(L) - 1]
for i in range(n):
	if L[i] != mini and L[i] != maxi:
		res = res + 1
print(res)


n = int(input())
s = list(map(int, input().split()))
result = 0
s.sort()
for i in s:
	if s[0] < i and s[n - 1] > i:
		result += 1
print(result)


n = int(input())
l = [int(i) for i in input().split()]
if min(l) == max(l):
	print(0)
else:
	print(len(l) - l.count(min(l)) - l.count(max(l)))


n = int(input())
s = list(map(int, input().split()))
a = s.count(max(s))
b = s.count(min(s))
if len(set(s)) <= 2:
	print(0)
else:
	print(n - (a + b))


input()
numList = [int(x) for x in input().split()]
freqDict = {}
for i in numList:
	if i in freqDict:
		freqDict[i] += 1
	else:
		freqDict[i] = 1
tot = 0
lo = 10 ** 10
loCount = 0
hi = -1
hiCount = 0
for i in freqDict:
	tot += freqDict[i]
	if i < lo:
		lo = i
		loCount = freqDict[i]
	if i > hi:
		hi = i
		hiCount = freqDict[i]
if lo == hi:
	print(0)
else:
	print(tot - loCount - hiCount)


n = int(input())
l1 = [int(num) for num in input().split(' ')]
if len(set(l1)) > 1:
	print(len(l1) - l1.count(max(l1)) - l1.count(min(l1)))
else:
	print('0')


def countingSort(arr, exp1):
	n = len(arr)
	output = [0] * n
	count = [0] * 10
	for i in range(0, n):
		index = arr[i] // exp1
		count[index % 10] += 1
	for i in range(1, 10):
		count[i] += count[i - 1]
	i = n - 1
	while i >= 0:
		index = arr[i] // exp1
		output[count[index % 10] - 1] = arr[i]
		count[index % 10] -= 1
		i -= 1
	i = 0
	for i in range(0, len(arr)):
		arr[i] = output[i]

def radixSort(arr):
	max1 = max(arr)
	exp = 1
	while max1 // exp > 0:
		countingSort(arr, exp)
		exp *= 10
n = int(input())
arr = [int(x) for x in input().split()]
radixSort(arr)
unsupport = 0
for i in range(0, n):
	if arr[i] == arr[0]:
		unsupport += 1
	else:
		break
for i in range(n - 1, 0, -1):
	if arr[n - 1] == arr[i]:
		unsupport += 1
	else:
		break
answer = n - unsupport
if answer < 0:
	print(0)
else:
	print(answer)


n = int(input().strip())
arr = list(map(int, input().strip().split()))
arr.sort()
c = 0
first = arr[0]
last = arr[-1]
for i in arr:
	if first < i < last:
		c += 1
print(c)


n = int(input())
l = list(map(int, input().split()))
if n == 1 or n == 2:
	print('0')
else:
	mi = min(l)
	ma = max(l)
	t = n - l.count(mi) - l.count(ma)
	if t > 0:
		print(t)
	else:
		print('0')


n = int(input())
l = list(map(int, input().split()))
l.sort()
lo = 0
while lo < n - 1 and l[lo] == l[lo + 1]:
	lo += 1
hi = n - 1
while hi > 0 and l[hi - 1] == l[hi]:
	hi -= 1
print(max(0, hi - lo - 1))


n = int(input())
a = list(map(int, input().split()))
mx = max(a)
mn = min(a)
ans = n
for i in range(n):
	if a[i] == mx or a[i] == mn:
		ans -= 1
print(ans)


n = int(input())
stews = input().strip().split(' ')
stews = [int(s) for s in stews]
if min(stews) == max(stews):
	print(0)
else:
	print(max(0, n - stews.count(min(stews)) - stews.count(max(stews))))


N = int(input())
A = list(map(int, input().split()))
mn = min(A)
mx = max(A)
ans = 0
for x in A:
	ans += mn < x < mx
print(ans)


n = int(input())
s = sorted(list(map(int, input().split())))
weakest = s[0]
strongest = s[len(s) - 1]
if len(s) < 3:
	print(0)
else:
	ans = 0
	for a in s:
		if a != weakest and a != strongest:
			ans += 1
	print(ans)


n = int(input())
A = [int(a) for a in input().split()]
a_min = min(A)
a_max = max(A)
print(sum(map(lambda a: a > a_min and a < a_max, A)))


n = int(input())
l = list(map(int, input().split()))
if n <= 2:
	print(0)
else:
	ans = 0
	x = min(l)
	y = max(l)
	for i in l:
		if i != x and i != y:
			ans += 1
	print(ans)


from fractions import Fraction
import sys
import bisect
import heapq
from math import *
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
mod = 1000000007

def inp():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def graph(vertex):
	return [[] for i in range(0, vertex + 1)]

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans

def createMatrix(rowCount, colCount, dataList):
	mat = []
	for i in range(rowCount):
		rowList = []
		for j in range(colCount):
			if dataList[j] not in mat:
				rowList.append(dataList[j])
		mat.append(rowList)
	return mat

def isprime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True
import collections

def minimalFilps1(bits):
	n = len(bits)
	flipsFromLeft = [0 for i in range(n)]
	flipsFromRight = [0 for i in range(n)]
	flips = 0
	for i in range(0, n, 1):
		if bits[i] == '1':
			flips = flips + 1
		flipsFromLeft[i] = flips
	flips = 0
	i = n - 1
	while i >= 0:
		if bits[i] == '0':
			flips = flips + 1
		i = i - 1
		flipsFromRight[i] = flips
	minFlips1 = sys.maxsize
	for i in range(1, n, 1):
		if flipsFromLeft[i - 1] + flipsFromRight[i] < minFlips1:
			minFlips1 = flipsFromLeft[i - 1] + flipsFromRight[i]
	return minFlips1

def minimalFilps(bits):
	n = len(bits)
	flipsFromLeft = [0 for i in range(n)]
	flipsFromRight = [0 for i in range(n)]
	flips = 0
	for i in range(0, n, 1):
		if bits[i] == '0':
			flips = flips + 1
		flipsFromLeft[i] = flips
	flips = 0
	i = n - 1
	while i >= 0:
		if bits[i] == '1':
			flips = flips + 1
		i = i - 1
		flipsFromRight[i] = flips
	minFlips = sys.maxsize
	for i in range(1, n, 1):
		if flipsFromLeft[i - 1] + flipsFromRight[i] < minFlips:
			minFlips = flipsFromLeft[i - 1] + flipsFromRight[i]
	return minFlips

def oddn(n):
	for i in range(2, n + 1):
		if i % 2 != 0 and n % i == 0:
			return i
	return 3
n = int(input())
a = list(map(int, input().split()))
b = 0
if n == 1 or n == 2:
	b = 0
else:
	c = min(a)
	d = max(a)
	for i in range(n):
		if a[i] > c and a[i] < d:
			b += 1
print(b)


n = int(input())
x = [int(x) for x in input().split()]
c = 0
if n <= 2:
	print(0)
else:
	g = max(x)
	l = min(x)
	for i in range(n):
		if l < x[i] < g:
			c = c + 1
	print(c)


n = int(input())
l = list(map(int, input().split()))
maximum = max(l)
minimum = min(l)
counter = 0
for i in range(n):
	if l[i] > minimum and l[i] < maximum:
		counter += 1
print(counter)


n = int(input())
sn = []
ans = 0
sn = list(map(int, input().split()))
list.sort(sn)
for i in range(n - 1):
	if (sn[0] < sn[i]) & (sn[n - 1] > sn[i]):
		ans += 1
print(ans)


n = int(input().strip())
a = list(map(int, input().strip().split()))
a.sort()
ans = 0
for x in a:
	if a[0] < x < a[n - 1]:
		ans += 1
print(ans)


N = int(input())
a = list(map(int, input().split()))
i = 1
ma = max(a)
mi = min(a)
if len(a) - a.count(ma) - a.count(mi) < 0:
	print(0)
else:
	print(len(a) - a.count(ma) - a.count(mi))


from collections import Counter
n = int(input())
seq = list(map(int, input().split()))
ans = Counter(seq)
answ = n - ans[min(seq)] - ans[max(seq)]
if answ < 0:
	print(0)
else:
	print(answ)


import os
import re
import sys
from bisect import bisect, bisect_left, insort, insort_left
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from io import BytesIO, IOBase
from itertools import accumulate, combinations, combinations_with_replacement, groupby, permutations, product
from math import acos, asin, atan, ceil, cos, degrees, factorial, hypot, log2, pi, radians, sin, sqrt, tan
from operator import itemgetter, mul
from string import ascii_lowercase, ascii_uppercase, digits

def inp():
	return int(input())

def inlist():
	return list(map(int, input().split()))

def instr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())

def main():
	n = inp()
	a = inlist()
	mini = min(a)
	maxi = max(a)
	res = 0
	for i in a:
		if mini < i and maxi > i:
			res += 1
	print(res)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
main()


n = int(input())
A = list(map(int, input().split()))
ans = 0
x = max(A)
y = min(A)
for i in range(len(A)):
	if A[i] > y and A[i] < x:
		ans += 1
print(ans)


N = int(input())
V = list(map(int, input().split()))
V.sort()
q = V[0]
ans = N
for i in range(0, N):
	if V[i] != q:
		break
	ans -= 1
q = V[-1]
for i in range(N - 1, 0, -1):
	if V[i] != q:
		break
	ans -= 1
if ans < 0:
	ans = 0
print(ans)
5


n = int(input())
l1 = [int(x) for x in input().split()]
s = min(l1)
l = max(l1)
print(max(0, len(l1) - l1.count(s) - l1.count(l)))


n = int(input())
stewards = tuple(map(int, input().split()))
(minimum, maximum) = (float('inf'), float('-inf'))
for i in stewards:
	if i > maximum:
		maximum = i
	if i < minimum:
		minimum = i
count = 0
for i in stewards:
	if minimum < i < maximum:
		count += 1
print(count)


input()
l = map(int, input().split())
l = list(l)
(a, b) = (max(l), min(l))
count = 0
for i in l:
	if i < a and i > b:
		count += 1
print(count)


n = int(input())
stw = list(map(int, input().split()))
mn = min(stw)
mx = max(stw)
count = 0
for el in stw:
	if mn < el < mx:
		count += 1
print(count)


import sys
n = int(input())
a = list(map(int, input().split()))
a.sort()
mn = a[0]
mx = a[-1]
ans = 0
for x in a:
	if mn < x < mx:
		ans += 1
print(ans)


(n, stewards) = (int(input().strip()), list(map(int, input().split())))
stewards.sort()
ans = 0
for i in range(1, len(stewards) - 1):
	try:
		if stewards[i] > stewards[0] and stewards[i] < stewards[-1]:
			ans += 1
	except:
		pass
print(ans)


n = int(input())
stw = list(map(int, input().split()))
maxs = max(stw)
mins = min(stw)
count = 0
for s in stw:
	if mins < s < maxs:
		count += 1
print(count)


n = int(input())
a = [int(x) for x in input().split()]
i = 0
mx = 0
mn = 100000000000
c1 = 0
c2 = 0
for x in a:
	if x > mx:
		mx = x
	if x < mn:
		mn = x
for x in a:
	if x == mx:
		c1 += 1
	if x == mn:
		c2 += 1
if mx == mn:
	print(0)
else:
	print(n - c1 - c2)


import sys
import os
if os.environ.get('DEBUGSTER_PYTHON'):
	sys.stdin = open('in.txt', 'r')
	sys.stdout = open('out.txt', 'w')
n = int(input())
a = list(map(int, input().split()))
a.sort()
mn = a[0]
mx = a[-1]
ans = 0
for x in a:
	if mn < x < mx:
		ans += 1
print(ans)


n = input()
r = lambda : list(map(int, input().split()))
arr = r()
mi = min(arr)
ma = max(arr)
c = 0
for i in arr:
	if i != mi and i != ma:
		c += 1
print(c)


def main():
	input()
	arr = [int(i) for i in input().split()]
	arr.sort()
	i = 0
	j = len(arr) - 1
	while arr[0] == arr[i] and i < len(arr) - 1:
		i += 1
	while arr[-1] == arr[j] and j >= 0:
		j -= 1
	if j >= i:
		print(j - i + 1)
	else:
		print(0)
main()


n = int(input())
a = [int(i) for i in input().split()]
if len(a) == 1:
	print('0')
else:
	print(len(a) - a.count(min(a)) - a.count(max(a))) if min(a) != max(a) else print('0')


n = int(input())
s = [int(x) for x in input().split(' ')]
r = 0
(m, b) = (max(s), min(s))
for i in s:
	if i != m and i != b:
		r += 1
print(r)


def dozor(lst):
	(result, minimum, maximum) = (0, min(lst), max(lst))
	for elem in lst:
		if elem != minimum and elem != maximum:
			result += 1
	return result
n = int(input())
a = [int(i) for i in input().split()]
print(dozor(a))


n = int(input())
a = [int(x) for x in input().split()]
a = sorted(a)
if n >= 3:
	b1 = False
	for i in range(1, n):
		if a[i] > a[0]:
			b1 = True
			break
	for j in range(n - 2, -1, -1):
		if a[j] < a[n - 1]:
			break
	if not b1:
		print(0)
	else:
		print(j - i + 1)
else:
	print(0)


n = int(input())
a = [int(x) for x in input().split(' ')]
m = min(a)
M = max(a)
ans = max(0, n - a.count(m) - a.count(M))
print(ans)


n = int(input())
v = [int(x) for x in input().split()]
mn = min(v)
mm = max(v)
ans = 0
for i in range(len(v)):
	if v[i] > mn and v[i] < mm:
		ans += 1
print(ans)


n = int(input())
lst = list(map(int, input().split()))
lst.sort()
ans = 0
for i in range(1, n - 1):
	if lst[0] < lst[i] and lst[i] < lst[-1]:
		ans += 1
print(ans)


x = int(input())
y = list(map(int, input().split()))
if x == 2:
	print(0)
else:
	y.sort()
	if max(y) == min(y) and x != 2:
		print(0)
	else:
		print(x - y.count(min(y)) - y.count(max(y)))


input()
a = list(map(int, input().split()))
mi = min(a)
ma = max(a)
ch = 0
for i in range(len(a)):
	if a[i] != mi and a[i] != ma:
		ch += 1
print(ch)


n = int(input())
arr = list(map(int, input().split()))
(maxx, minn) = (max(arr), min(arr))
count = 0
for i in arr:
	if i > minn and i < maxx:
		count += 1
print(count)


n = int(input())
li = list(map(int, input().split()))
li.sort()
l = []
for i in li:
	if i != li[0] and i != li[-1]:
		l.append(i)
print(len(l))


a0 = int(input())
l = [int(i) for i in input().split(' ')]
(mi, me) = (min(l), max(l))
c = 0
for i in l:
	if i > mi and i < me:
		c = c + 1
print(c)


n = int(input())
ls = sorted(list(map(int, input().split())))
ans = 0
if len(set(ls)) < 3:
	print(0)
else:
	first = ls[0]
	last = ls[-1]
	f = ls.count(first)
	l = ls.count(last)
	ans = len(ls) - (f + l)
	print(ans)


n = int(input())
mat = list(map(int, input().split()))
print(max(0, n - mat.count(min(mat)) - mat.count(max(mat))))


n = int(input())
s = list(map(int, input().split()))
print(max(0, n - s.count(min(s)) - s.count(max(s))))


n = int(input())
stewards = sorted(list(map(int, input().split())))
sol = 0
mn = min(stewards)
mx = max(stewards)
for elem in stewards:
	if mn < elem < mx:
		sol += 1
print(sol)


n = int(input())
a = sorted([int(i) for i in input().split()])
ans = n
ans -= a.count(a[0])
ans -= a.count(a[n - 1])
print(max(0, ans))


n = int(input())
list1 = list(map(int, input().split(' ')))
m = min(list1)
M = max(list1)
count = 0
for i in list1:
	if i > m and i < M:
		count += 1
print(count)


n = int(input())
List = list(map(int, input().split()))
List.sort()
cntb = List.count(List[-1])
cnta = List.count(List[0])
if cnta + cntb > len(List):
	print(0)
elif len(List) > 2:
	print(len(List) - 2 - cnta + 1 - cntb + 1)
else:
	print(0)


n = int(input())
s = input().split()
s = list(map(int, s))
ma = max(s)
mi = min(s)
p = len(s)
for t in s:
	if t == ma or t == mi:
		p -= 1
print(p)


a = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
k = max(l)
k1 = min(l)
for i in l:
	if i != k and i != k1:
		ans += 1
print(ans)


n = int(input())
a = [int(x) for x in input().split()]
a.sort()
if len(set(a)) <= 2:
	print(0)
else:
	first = 0
	while a[first] == a[0]:
		first += 1
	second = len(a) - 1
	while a[second] == a[len(a) - 1]:
		second -= 1
	print(second - first + 1)


R = lambda : map(int, input().split())
n = int(input())
arr = sorted(list(R()))
print(max(0, len(arr) - arr.count(arr[0]) - arr.count(arr[-1])))


N = int(input())
A = list(map(int, input().split()))
A.sort()
count = 1
countlist = []
ans = 0
for i in range(1, N):
	if A[i] != A[i - 1]:
		countlist.append(count)
		count = 1
	else:
		count += 1
countlist.append(count)
for i in range(1, len(countlist) - 1):
	ans += countlist[i]
print(ans)


n = int(input())
l = list(map(int, input().split()))
small = min(l)
big = max(l)
count = 0
for x in l:
	if x != small and x != big:
		count += 1
print(count)


t = int(input())
l = [int(i) for i in input().split()]
mx = max(l)
mn = min(l)
count = 0
for i in l:
	if i > mn and i < mx:
		count += 1
print(count)


import sys
n = int(input())
L = [int(x) for x in input().split()]
count = 2
L.sort()
if len(set(L)) <= 2:
	print(0)
	sys.exit(0)
i = 0
while i < n - 1 and L[i] == L[i + 1]:
	count += 1
	i += 1
i = -1
while i > -n and L[i] == L[i - 1]:
	count += 1
	i = i - 1
print(n - count)


n = int(input())
a = sorted(map(int, input().split()))
res = 0
for i in range(1, n - 1):
	if a[0] < a[i] < a[-1]:
		res += 1
print(res)


n = int(input())
s = [int(x) for x in input().split()]
s.sort()
mi = min(s)
mx = max(s)
n_min = 0
n_max = 0
for i in s:
	if i == mi:
		n_min = n_min + 1
	elif i == mx:
		n_max = n_max + 1
l = len(s)
print(l - n_max - n_min)


n = int(input())
a = [int(i) for i in input().split()]
b = max(a)
c = min(a)
for i in a:
	if i == b or i == c:
		n -= 1
print(n)


n = int(input())
mx_i = 0
mx_cnt = 0
mn_i = 0
mn_cnt = 0
arr = list(map(int, input().split()))
for i in range(n):
	if arr[i] > arr[mx_i]:
		mx_i = i
		mx_cnt = 1
	elif arr[i] == arr[mx_i]:
		mx_cnt += 1
	if arr[i] < arr[mn_i]:
		mn_i = i
		mn_cnt = 1
	elif arr[i] == arr[mn_i]:
		mn_cnt += 1
print(max(0, n - mx_cnt - mn_cnt))


from collections import Counter
n = int(input())
stewards = list(map(int, input().split()))
max_element = max(stewards)
min_element = min(stewards)
count_dict = Counter(stewards)
if min_element == max_element:
	print(0)
else:
	print(n - count_dict[max_element] - count_dict[min_element])


n = int(input())
li = [int(x) for x in input().strip().split(' ')]
mx = max(li)
mn = min(li)
c = 0
for j in li:
	if j < mx and j > mn:
		c += 1
print(c)


n = int(input())
l = list(map(int, input().split()))
c = 0
m = max(l)
k = min(l)
for i in range(n):
	if l[i] > k and l[i] < m:
		c += 1
print(c)


n = int(input())
a = list(map(int, input().split()))
if n < 3:
	print(0)
	exit()
a.sort()
mn = a.count(a[0])
mx = a.count(a[n - 1])
print(max(0, n - mx - mn))


from collections import Counter
n = int(input())
a = sorted(map(int, input().split()))
if len(a) <= 2:
	print(0)
else:
	cnt = Counter(a)
	b = []
	seen = set()
	for x in a:
		if x not in seen:
			b.append(x)
			seen.add(x)
	ans = 0
	for x in b[1:-1]:
		ans += cnt[x]
	print(ans)


def jon(arr):
	big = max(arr)
	smol = min(arr)
	smol_count = 0
	big_count = 0
	for i in arr:
		if i == smol:
			smol_count += 1
		if i == big:
			big_count += 1
	if big == smol:
		return 0
	ans = len(arr) - big_count - smol_count
	return ans
n = int(input())
ar = list(map(int, input().rstrip().split()))
print(jon(ar))


n = int(input())
l = [int(x) for x in input().split()]
if len(l) <= 2:
	print(0)
else:
	(mx, mn) = (max(l), min(l))
	if mx == mn:
		print(0)
	else:
		cnt_feed = l.count(mx) + l.count(mn)
		print(n - cnt_feed)


n = int(input())
l = sorted(map(int, input().split()))
ans = 0
for i in range(1, n - 1):
	if l[0] < l[i] < l[-1]:
		ans += 1
print(ans)


n = int(input())
array = list(map(int, input().strip().split()))
array.sort()
answer = 0
for i in range(1, n - 1):
	if array[i] > array[0] and array[i] < array[n - 1]:
		answer += 1
print(answer)


n = int(input())
arr = [int(x) for x in input().split()]
arr.sort()
count = 0
for i in range(1, n - 1):
	if arr[i] > arr[0] and arr[i] < arr[n - 1]:
		count += 1
print(count)


n = int(input())
s = [int(i) for i in input().split()]
a = max(s)
b = min(s)
ans = 0
for i in s:
	if i != a and i != b:
		ans += 1
print(ans)


n = int(input())
a = list(map(int, input().split()))
big = max(a)
small = min(a)
count = 0
for i in a:
	if i > small and i < big:
		count += 1
print(count)


import sys
itemsCount = int(sys.stdin.readline())
minValue = -1
minValueCount = 1
maxValue = -1
maxValueCount = 1
count = 0
i = 0
while i < itemsCount:
	valid = True
	l = sys.stdin.read(1)
	item = ''
	while l != ' ' and l != '\n' and (l != ''):
		item += l
		l = sys.stdin.read(1)
	item = int(item)
	if minValue == -1 and maxValue == -1:
		minValue = maxValue = item
		i += 1
		continue
	if item < minValue:
		if minValue != maxValue:
			count += minValueCount
		minValue = item
		minValueCount = 1
	elif item == minValue:
		minValueCount += 1
	if item > maxValue:
		if minValue != maxValue:
			count += maxValueCount
		maxValue = item
		maxValueCount = 1
	elif item == maxValue:
		maxValueCount += 1
	if item > minValue and item < maxValue:
		count += 1
	i += 1
sys.stdin.close()
print(count)


n = int(input())
l_s = list(map(int, input().split()))
t = 0
l = min(l_s)
m = max(l_s)
for s in l_s:
	if s != l and s != m:
		t += 1
print(t)


n = int(input())
arr = list(map(int, input().split()))
print(max(0, len(arr) - arr.count(min(arr)) - arr.count(max(arr))))


n = int(input())
a = sorted(list(map(int, input().split())))
x = a.count(a[0])
y = a.count(a[-1])
if n - x - y >= 0:
	print(n - x - y)
else:
	print(0)


n = int(input())
k = list(map(int, input().split()))
mn = min(k)
mx = max(k)
ans = 0
for i in k:
	if mn != i != mx:
		ans += 1
print(ans)


nb_steward = int(input())
stewards = list(map(int, input().split()))
stewards.sort()
i = 0
count = 0
while i < nb_steward:
	if stewards[i] > stewards[0] and stewards[nb_steward - 1] > stewards[i]:
		count += 1
	i += 1
print(count)


input()
data = list(map(int, input().split()))
excluded = {max(data), min(data)}
print(sum(map(lambda v: v not in excluded, data)))


n = int(input())
nums = list(map(int, input().split(' ')))
nums.sort()
mini = nums[0]
maxi = nums[-1]
res = 0
for i in range(1, len(nums) - 1):
	if nums[i] > mini and nums[i] < maxi:
		res += 1
print(res)


n = int(input())
a = sorted(list(map(int, input().split())))
out = 0
for i in range(1, n - 1):
	if a[0] < a[i] < a[-1]:
		out += 1
print(out)


n = int(input())
l = list(map(int, input().split()))
cnt = 0
z = min(l)
z1 = max(l)
for i in l:
	if i > z and i < z1:
		cnt += 1
print(cnt)


li = int(input())
n = list(map(int, input().rstrip().split()))
n.sort()
maxa = n[len(n) - 1]
mini = n[0]
fi = 0
i = 0
while i < len(n) and (len(n) > 1 and (maxa == n[li - 1] or mini == n[fi])):
	i += 1
	if n[fi] == mini:
		fi += 1
	if maxa == n[li - 1]:
		li -= 1
if len(n) == 1:
	print(0)
else:
	print(len(n[fi:li]))


n = int(input())
s = 0
stuards = sorted(list(map(int, input().split())))
for stuard in stuards:
	if stuards[0] < stuard < stuards[-1]:
		s += 1
print(s)


n = int(input())
a = list(map(int, input().split()))
(Min, Max) = (min(a), max(a))
(c1, c2) = (a.count(Min), a.count(Max))
n = n - c1 - c2
print(n if n > 0 else 0)


n = int(input())
a = list(map(int, input().split()))
if n <= 2:
	print(0)
else:
	support = 0
	a.sort()
	for i in range(1, n - 1):
		if a[i] < a[n - 1] and a[i] > a[0]:
			support += 1
	print(support)


n = int(input())
lst = list(map(int, input().split()))
mi = min(lst)
mx = max(lst)
count = 0
for i in range(n):
	if mi < lst[i] and lst[i] < mx:
		count += 1
print(count)


n = int(input())
strenghts = list(map(int, input().strip().split(' ')))
strenghts.sort()
minimo = strenghts[0]
maximo = 0
if n > 1:
	maximo = strenghts[n - 1]
counter = 0
for i in range(1, n - 1):
	aux = strenghts[i]
	if minimo < aux and aux < maximo:
		counter += 1
print(counter)


n = input()
s = list(map(int, input().split()))
s.sort()
counter = 0
for i in range(0, int(n) - 2, 1):
	if s[i] < s[i + 1]:
		temp = i + 1
		while s[temp] == s[temp + 1]:
			temp += 1
			if temp == int(n) - 1:
				counter -= temp - i
				break
		counter += temp - i
		i = temp
print(counter)


n = int(input())
st = list(map(int, input().split()))
st.sort()
f = st[0]
l = st[-1]
res = len([i for i in st if i != f and i != l])
print(res)


def Main():
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	s = set(arr)
	if len(s) == 1 or len(s) == 2:
		print(0)
		return 0
	fs = arr[0]
	ls = arr[len(arr) - 1]
	cnt1 = arr.count(fs)
	cnt2 = arr.count(ls)
	print(len(arr) - (cnt1 + cnt2))
Main()


n = int(input())
stewards = input()
stewards = [int(i) for i in stewards.split()]
strength = max(stewards)
wick = min(stewards)
snow = 0
for i in stewards:
	if i > wick and i < strength:
		snow += 1
print(snow)


n = int(input())
arr = list(map(int, input().split()))
arr = sorted(arr)
l = 0
r = n - 1
while l <= n - 1 and arr[l] == arr[0]:
	l += 1
while r >= 0 and arr[r] == arr[n - 1]:
	r -= 1
ans = max(r - l + 1, 0)
print(ans)


n = int(input())
v = [int(x) for x in input().split()]
an = 0
if n < 3:
	an = 0
else:
	(mn, mx) = (min(v), max(v))
	for i in v:
		if i > mn and i < mx:
			an += 1
print(an)


n = int(input())
ls = list(map(int, input().split()))
mn = int(1000000000.0) + 5
mx = int(-1)
for i in ls:
	mx = max(i, mx)
	mn = min(i, mn)
ans = 0
for i in ls:
	if i > mn and i < mx:
		ans += 1
print(ans)


n = int(input())
stewards = [int(x) for x in input().split()]
m_stewards = min(stewards)
x_stewards = max(stewards)
c = 0
for s in stewards:
	if s > m_stewards and s < x_stewards:
		c += 1
print(c)


n = int(input())
L = []
s = input().split()
for i in s:
	L.append(int(i))
maxl = max(L)
minl = min(L)
c = 0
for i in L:
	if minl < i < maxl:
		c = c + 1
print(c)


n = int(input())
stewards = [int(x) for x in input().split(' ')]
stewards.sort()
filteredStewards = list(filter(lambda x: x > stewards[0] and x < stewards[n - 1], stewards))
print(len(filteredStewards))


n = input()
s = [int(x) for x in input().split()]
count = len(s) - s.count(min(s)) - s.count(max(s))
if count < 0:
	print('0')
else:
	print(count)


n = int(input())
l = list(map(int, input().split()))
l.sort()
min = l[0]
max = l[n - 1]
a = l.count(min)
b = l.count(max)
if min == max:
	print('0')
elif n > 2:
	print(n - a - b)
else:
	print('0')


n = int(input())
vls = list(map(int, input().split()))
if n > 1:
	vls.sort()
	cnt = 0
	for i in range(1, n - 1):
		if vls[i] > vls[0] and vls[i] < vls[n - 1]:
			cnt += 1
	print(cnt)
else:
	print(0)


n = int(input())
a = list(map(int, input().split()))
m = min(a)
M = max(a)
count = 0
for el in a:
	if el != m and el != M:
		count += 1
print(count)


n = int(input())
a = list(map(int, input().split()))
ma = a.count(max(a))
mi = a.count(min(a))
b = max(0, n - ma - mi)
print(b)


n = int(input())
arr = list(map(int, input().split()))
arr = sorted(arr)
cnt = 0
for i in arr:
	if i > arr[0] and i < arr[-1]:
		cnt += 1
print(cnt)


n = int(input())
arr = list()
inp = input().split()
for i in inp:
	arr.append(int(i))
arr.sort()
min = arr[0]
max = arr[-1]
count = 0
for i in range(0, n):
	if arr[i] - min >= 1 and max - arr[i] >= 1:
		count += 1
print(count)


n = int(input())
x = [int(x) for x in input().split()]
x.sort()
a = len(set(x))
cnt = 0
if a <= 2:
	print(0)
else:
	for i in range(n):
		if x[i] == x[0] or x[i] == x[-1]:
			cnt += 1
	print(len(x) - cnt)


n = int(input())
stewards = list(map(int, input().split()))
mini = min(stewards)
maxi = max(stewards)
sum = 0
for i in stewards:
	if mini < i < maxi:
		sum += 1
print(sum)


n = int(input())
stewards = list(map(int, input().split()))
stewards.sort()
count = 0
m1 = stewards[0]
m2 = stewards[n - 1]
for i in range(1, n - 1):
	if stewards[i] > m1 and stewards[i] < m2:
		count += 1
print(count)


n = int(input())
i = list(map(int, input().split()))
print(max(0, n - i.count(max(i)) - i.count(min(i))))


a = int(input())
b = list(map(int, input().split()))
c = min(b)
d = max(b)
x = b.count(c)
y = b.count(d)
z = a - (x + y)
if z < 0:
	print(0)
else:
	print(z)


n = int(input())
a = list(map(int, input().split()))
(low, high) = (min(a), max(a))
res = 0
for x in a:
	if x != low and x != high:
		res += 1
print(res)


n = int(input())
l = list(map(int, input().split()))
(MIN, MAX) = (min(l), max(l))
if MIN == MAX:
	MIN = -999999999999999
print(len(l) - l.count(MIN) - l.count(MAX))


n = int(input())
v = list(map(int, input().split()))
smallest = v[0]
biggest = v[0]
numsmallest = 1
numbiggest = 1
for i in range(1, n):
	if v[i] == smallest:
		numsmallest = numsmallest + 1
	if v[i] == biggest:
		numbiggest = numbiggest + 1
	if v[i] < smallest:
		smallest = v[i]
		numsmallest = 1
	elif v[i] > biggest:
		biggest = v[i]
		numbiggest = 1
if n - numsmallest - numbiggest < 0:
	print(0)
else:
	print(n - numsmallest - numbiggest)


t = int(input())
x = [int(q) for q in input().split()]
s = 0
s = len(x) - x.count(max(x)) - x.count(min(x))
print(max(0, s))


import math
import os
import random
import re
from sys import stdin, stdout
from collections import Counter
from itertools import permutations

def si():
	return str(stdin.readline())

def ii():
	return int(stdin.readline())

def mi():
	return map(int, stdin.readline().split())

def li():
	return list(mi())

def debug(x):
	return stdout.write(str(x))
n = ii()
arr = li()
m1 = min(arr)
m2 = max(arr)
ans = []
c1 = 0
c2 = 0
for i in range(n):
	if arr[i] == m1:
		c1 += 1
	if arr[i] == m2:
		c2 += 1
if m1 == m2:
	debug(0)
else:
	debug(n - c1 - c2)


n = int(input())
ai = list(map(int, input().split()))
m1 = max(ai)
m2 = min(ai)
ai2 = [ai[i] != m1 and ai[i] != m2 for i in range(n)]
print(sum(ai2))


n = input().strip()
n = int(n)
stew = list(map(int, input().strip().split(' ')))
stew.sort()
min_val = stew[0]
max_val = stew[len(stew) - 1]
val = n - stew.count(min_val) - stew.count(max_val)
if val < 1:
	val = 0
print(val)


n = map(int, input().split())
a = list(map(int, input().split()))
a_max = max(a)
a_min = min(a)
c = 0
for i in a:
	if i != a_max and i != a_min:
		c = c + 1
print(c)


n = int(input())
a = list(map(int, input().split()))
x = max(a)
y = min(a)
i = 0
count = 0
while i < n:
	if a[i] < x and a[i] > y:
		count = count + 1
	i = i + 1
print(count)


n = int(input())
strengths = list(map(int, input().strip().split()))
least = min(strengths)
most = max(strengths)
ans = 0
for i in strengths:
	if i > least and i < most:
		ans += 1
print(ans)


n = int(input())
a = list(map(int, input().split()))
a.sort()
mina = a[0]
maxa = a[len(a) - 1]
t = 0
for i in a:
	if i > mina and i < maxa:
		t = t + 1
print(t)


n = int(input())
l = list(map(int, input().strip().split()))
mini = min(l)
maxi = max(l)
count = 0
for i in l:
	if i > mini and i < maxi:
		count += 1
print(count)


n = int(input())
line = list(map(int, input().split()))
min_c = max_c = 0
min_v = max_v = line[0]
for it in line:
	if it < min_v:
		(min_c, min_v) = (1, it)
	elif it == min_v:
		min_c += 1
	if it > max_v:
		(max_c, max_v) = (1, it)
	elif it == max_v:
		max_c += 1
if max_v == min_v:
	print(0)
else:
	print(n - max_c - min_c)


n = int(input())
stewards = sorted((int(c) for c in input().split()))
(_min, _max) = (min(stewards), max(stewards))
ans = sum((1 for e in stewards if e != _min and e != _max))
print(ans)


n = int(input())
a = [int(x) for x in input().split()]
a.sort()
(i, j) = (-1, -1)
for i in range(1, len(a)):
	if a[i] > a[i - 1]:
		break
for j in range(len(a) - 2, -1, -1):
	if a[j] < a[j + 1]:
		break
if i > j or i < 0 or j < 0:
	print(0)
else:
	print(j - i + 1)


alph = 'abcdefghijklmnopqrstuvwxyz'
n = int(input())
a = list(map(int, input().split()))
print(max(0, n - a.count(min(a)) - a.count(max(a))))


n = int(input())
a = [int(x) for x in input().split()]
mina = a[0]
maxa = a[0]
mincount = 1
maxcount = 1
for i in range(1, n):
	if a[i] == mina:
		mincount += 1
	elif a[i] < mina:
		mina = a[i]
		mincount = 1
	if a[i] == maxa:
		maxcount += 1
	elif a[i] > maxa:
		maxa = a[i]
		maxcount = 1
n = n - mincount - maxcount
if n < 0:
	n = 0
print(n)


n = int(input())
a = list(map(int, input().split()))
ans = 0
if n < 3:
	ans = 0
else:
	(x, y) = (min(a), max(a))
	for i in range(n):
		if a[i] > x and a[i] < y:
			ans += 1
print(ans)


n = int(input())
string = input()
numbers = string.split()
for x in range(n):
	numbers[x] = int(numbers[x])
a = n - numbers.count(min(numbers)) - numbers.count(max(numbers))
if a < 0:
	a = 0
print(a)


n = int(input())
nums = sorted(list(map(int, input().split(' '))))
count = 0
(mn, mx) = (min(nums), max(nums))
for i in range(1, len(nums) - 1):
	if nums[i] != mn and nums[i] != mx:
		count += 1
print(count)


n = int(input())
a = list(map(int, input().split()))
a.sort()
count = 2
tuki = 0
i = 1
lol = 0
if len(a) <= 2:
	print('0')
	quit()
while 1:
	if a[0] == a[i]:
		count += 1
		if count == n:
			print('0')
			quit()
		i += 1
		lol += 1
	elif tuki == 0:
		a.reverse()
		i = 1
		tuki += 1
	else:
		break
	if lol == n:
		break
if n - count > 0:
	print(n - count)
else:
	print('0')


n = int(input())
inp = list(map(int, input().split()))
inp.sort()
cntr = 0
for i in range(1, n - 1):
	if inp[0] < inp[i] < inp[n - 1]:
		cntr += 1
print(cntr)


n = int(input())
a = [int(i) for i in input().split()]
a = sorted(a)
(c, d) = (a.count(a[0]), a.count(a[n - 1]))
if n - c - d >= 0:
	print(n - c - d)
else:
	print(0)


n = int(input())
s = [int(x) for x in input().split()]
s = sorted(s)
count = len(s)
for i in range(0, len(s)):
	if s[i] == s[0]:
		count -= 1
	elif s[i] == s[-1]:
		count -= 1
print(count)


def main():
	input()
	l = list(map(int, input().split()))
	print(max(0, len(l) - l.count(min(l)) - l.count(max(l))))
main()


in1 = int(input())
l1 = list(map(int, input().split()))
mx = max(l1)
mini = min(l1)
x = list(filter(lambda x: x < mx and x > mini, l1))
print(len(x))


f = lambda : map(int, input().split())
a = int(input())
l = list(f())
c = 0
if a < 3:
	print(0)
else:
	l.sort()
	for i in range(a):
		if l[i] != l[0] and l[i] != l[-1]:
			c += 1
	print(c)


n = int(input())
stewards = list(map(int, input().split()))
stewards.sort()
minimum = stewards[0]
maximum = stewards[n - 1]
support = 0
for x in range(len(stewards)):
	if stewards[x] != minimum and stewards[x] != maximum:
		support += 1
print(support)


n = int(input())
v = list(map(int, input().split()))
mina = 1000000000000000000000
maxa = -1
minn = 0
maxn = 0
for i in v:
	if i < mina:
		mina = i
		minn = 1
	elif i == mina:
		minn += 1
	if i > maxa:
		maxa = i
		maxn = 1
	elif i == maxa:
		maxn += 1
print(max(0, n - maxn - minn))


input()
s = sorted([int(i) for i in input().split()])
m = s[0]
M = s[-1]
n = 0
for i in s:
	if m < i < M:
		n += 1
print(n)


n = int(input())
a = list(map(int, input().split()))
mn = 1000000001
mx = 0
cnt = 0
for x in a:
	if x < mn:
		mn = x
	if x > mx:
		mx = x
for x in a:
	if x > mn and x < mx:
		cnt += 1
print(cnt)


n = int(input())
a = list(map(int, input().split()))
(min_a, max_a) = (min(a), max(a))
print(max(0, n - a.count(min_a) - a.count(max_a)))


n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
ma = max(a)
mi = min(a)
num = 0
for i in range(n):
	if mi < a[i] < ma:
		num += 1
print(num)


def main():
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	worst = a[0]
	best = a[-1]
	ans = 0
	for x in a:
		if worst < x and x < best:
			ans += 1
	print(ans)
main()


n = int(input())
stewards = sorted(list(map(int, input().split())))
help = 0
mx = max(stewards)
mn = min(stewards)
for each in stewards:
	if mn < each < mx:
		help += 1
print(help)


n = int(input())
x = list(map(int, input().split()))
if len(x) > 2:
	maxx = max(x)
	minn = min(x)
	maxxc = x.count(maxx)
	minnc = x.count(minn)
	if maxx == minn:
		print(0)
	else:
		print(len(x) - maxxc - minnc)
else:
	print(0)


n = int(input())
arr1 = list(map(int, input().split()))
arr1.sort()
c = 0
for i in arr1:
	if arr1[0] < i < arr1[-1]:
		c += 1
print(c)


i = int(input())
A = list(map(int, input().split()))
A = sorted(A)
a_min = A[0]
a_max = A[len(A) - 1]
B = []
for i in range(1, len(A) - 1):
	if A[i] != a_min and A[i] != a_max:
		B.append(A[i])
print(len(B))


n = int(input())
a = list(map(int, input().split()))
a.sort()
s = set(a)
if len(s) < 3:
	print(0)
else:
	while True:
		if a[0] == a[1]:
			a.remove(a[0])
		else:
			break
	while True:
		if a[-1] == a[-2]:
			a.pop()
		else:
			break
	print(len(a) - 2)


n = int(input())
num = list(map(int, input().split()))
excluded = {max(num), min(num)}
print(sum(map(lambda v: v not in excluded, num)))


s = input()
l = list(map(int, input().split()))
l = sorted(l)
c = 0
for i in range(1, len(l) - 1):
	if l[i] > l[0] and l[i] < l[-1]:
		c += 1
print(c)


n = int(input())
a = list(map(int, input().split()))
x = max(a)
y = min(a)
if x == y:
	print(0)
else:
	print(n - a.count(x) - a.count(y))


n = int(input())
ip = input()
ip2 = ip.split(' ')
ip2 = list(map(int, ip2))
op = 0
mn = min(ip2)
mx = max(ip2)
for y in ip2:
	if mn < y and mx > y:
		op = op + 1
print(op)


n = input()
array = list(map(int, input().split()))
_min = min(array)
_max = max(array)
count = 0
for num in array:
	if num != _min and num != _max:
		count += 1
print(count)


n = int(input())
s = sorted(list(map(int, input().split())))
if len(s) <= 2:
	print(0)
else:
	t = n - 2 - (s.count(s[0]) - 1) - (s.count(s[-1]) - 1)
	print(max(t, 0))


n = int(input())
a = [int(x) for x in input().split()]
(mn, mx) = (min(a), max(a))
cnt = 0
for a_i in a:
	if a_i != mn and a_i != mx:
		cnt += 1
print(cnt)


n = int(input())
strengths = [int(x) for x in input().split()]
strengths.sort()
num = 0
for i in range(1, len(strengths) - 1):
	if strengths[i] > strengths[0] and strengths[i] < strengths[-1]:
		num += 1
print(num)


n = int(input())
d = {}
for k in map(int, input().split()):
	if k in d:
		d[k] += 1
	else:
		d[k] = 1
L = sorted(list(d.keys()))
suma = 0
for k in range(1, len(L) - 1):
	suma += d[L[k]]
print(suma)


n = int(input())
a = [int(x) for x in input().split()]
a.sort()
x = a[0]
y = a[n - 1]
c1 = a.count(x)
c2 = a.count(y)
l = len(a)
if l == 1 or x == y:
	print(0)
else:
	print(l - c1 - c2)


R = lambda : map(int, input().split())
(n,) = R()
l = list(R())
(x, c) = (min(l), max(l))
print(max(0, n - (l.count(c) + l.count(x))))


n = int(input())
arr = list(map(int, input().split()))
(mn, mx) = (min(arr), max(arr))
print(sum((1 for a in arr if mn < a < mx)))


x = int(input())
k = list(map(int, input().split()))
v = min(k)
m = max(k)
n = 0
for i in range(len(k)):
	if v < k[i] < m:
		n = n + 1
print(n)


n = int(input())
s = sorted(map(int, input().split()))
c = 0
for i in s:
	if s[0] < i < s[-1]:
		c += 1
print(c)


n = int(input())
X = [int(x) for x in input().split(' ')]
d = X.count(min(X))
c = X.count(max(X))
if n > 2:
	if n - d - c > 0:
		print(n - d - c)
	else:
		print(0)
else:
	print(0)


input()
stewards = list(map(int, input().split()))
helped = 0
min = min(stewards)
max = max(stewards)
for steward in sorted(stewards)[1:-1]:
	if steward != min and steward != max:
		helped += 1
print(helped)


n = int(input())
a = list(map(int, input().split()))
b = max(a)
c = min(a)
count = 0
for i in a:
	if c < i < b:
		count += 1
print(count)


n = int(input())
A = list(map(int, input().split()))
if n == 2:
	print('0')
	exit()
Max = A.count(max(A))
Min = A.count(min(A))
if max(A) == min(A):
	Min = 0
print(n - (Max + Min))


n = int(input())
lis = list(map(int, input().split()))
ma = max(lis)
mi = min(lis)
l = n - lis.count(ma) - lis.count(mi)
print(0) if l < 0 else print(l)


n = int(input())
v = list(map(int, input().split()))
if v == [v[0]] * n:
	print(0)
else:
	print(n - v.count(min(v)) - v.count(max(v)))


import math
m = 1000000007

def fact(n):
	ans = 1
	for i in range(1, n + 1):
		ans = ans % m * (i % m) % m
	return ans

def power_2(n):
	ans = 1
	for i in range(n):
		ans = ans % m * 2 % m
	return ans
n = int(input())
a = [int(i) for i in input().split()]
if min(a) == max(a):
	print(0)
else:
	print(n - a.count(max(a)) - a.count(min(a)))


n = int(input())
if n < 3:
	print(0)
	exit(0)
l = list(map(int, input().split(' ')))
l.sort()
h = l.pop(0)
t = l.pop()
while len(l) > 0 and h == l[0]:
	l.pop(0)
while len(l) > 0 and t == l[len(l) - 1]:
	l.pop()
print(len(l))


n = int(input())
ip = input().split(' ')
ip = list(map(int, ip))
ip = sorted(ip)
mn = min(ip)
mx = max(ip)
count = 0
for x in ip:
	if x > mn and x < mx:
		count += 1
print(count)


n = int(input())
stewards = list(map(int, input().split()))
mini = min(stewards)
maxi = max(stewards)
print(len(list(filter(lambda x: mini < x < maxi, stewards))))


n = int(input())
a = [int(x) for x in input().split()]
a = sorted(a)
minimum = a.count(a[0])
maximum = a.count(a[-1])
print(max(0, len(a) - minimum - maximum))


n = int(input())
t = input().split()
l = list(map(int, t))
if len(l) == 1 or len(l) == 2:
	print(0)
elif len(l) > 2 and len(set(l)) <= 2:
	print(0)
else:
	print(n - (l.count(min(l)) + l.count(max(l))))


n = int(input())
c = list(map(int, input().split()))
n = len(c)
x = max(c)
y = min(c)
m = c.count(x)
l = c.count(y)
if x != y:
	print(n - m - l)
else:
	print(0)


n = int(input())
data = list(map(int, input().split()))
print(max(0, n - data.count(max(data)) - data.count(min(data))))


from sys import stdin, stdout
n = int(stdin.readline())
power = sorted(list(map(int, stdin.readline().split())))
ans = 0
for i in range(n):
	if power[i] != power[0] and power[i] != power[-1]:
		ans += 1
stdout.write(str(ans))


n = int(input())
s = [int(i) for i in input().split()]
if max(s) != min(s):
	a = s.count(max(s))
	b = s.count(min(s))
	print(n - a - b)
else:
	print(0)


a = int(input())
b = list(map(int, input().split()))
b = sorted(b)
if a <= 1 or b[0] == b[-1]:
	print(0)
else:
	print(a - (b.count(b[0]) + b.count(b[-1])))


n = int(input())
lis = list(map(int, input().split()))
lis.sort()
a = lis[0]
b = lis[-1]
count = 0
for i in lis:
	if i > a and i < b:
		count += 1
print(count)


n = int(input())
a = list(map(int, input().split()))
a.sort()
mini = min(a)
maxi = max(a)
print(max(n - a.count(mini) - a.count(maxi), 0))


n = int(input())
a = list(map(int, input().split()))
a.sort()
p = 0
while p < n and a[p] == a[0]:
	p += 1
q = n - 1
while q >= 0 and a[q] == a[n - 1]:
	q -= 1
res = max(0, q - p + 1)
print(res)


n = int(input())
s = list(map(int, input().split()))
x = 0
s.sort()
for i in range(1, int(n) - 1):
	if (int(s[0]) < int(s[i])) & (int(s[int(n) - 1]) > int(s[i])):
		x += 1
print(x)


n = int(input('').strip())
a = map(int, input('').strip().split())
a = list(sorted(a))
count = 0
for i in range(n):
	if a[i] == a[0]:
		count += 1
	elif a[i] == a[-1]:
		count += 1
print(n - count, '\n')


from sys import exit
n = int(input())
strengths = sorted((int(i) for i in input().split()))
supported = n
(lowest, highest) = (strengths[0], strengths[-1])
if lowest == highest:
	print(0)
	exit(0)
i = 0
while strengths[i] == lowest:
	supported -= 1
	i += 1
i = n - 1
while strengths[i] == highest:
	supported -= 1
	i -= 1
print(supported)


n = int(input())
stewards = list(map(int, input().strip().split()))[:n]
stewards.sort()
s = 0
if n > 2:
	for i in range(n):
		if stewards[i] > stewards[0] and stewards[i] < stewards[-1]:
			s += 1
	print(s)
else:
	print(0)


import sys
input = sys.stdin.readline
n = int(input())
stuff = list(map(int, input().split()))
a = min(stuff)
b = max(stuff)
ans = 0
for i in stuff:
	if a < i < b:
		ans += 1
print(ans)


n = int(input())
l = list(map(int, input().split()))
l.sort()
s = list(set(l))
if len(s) <= 2:
	print(0)
else:
	l = l[l.index(s[1]):l.index(s[-1])]
	print(len(l))


n = int(input())
stw = list(map(int, input().split()))
(mn, mx) = (min(stw), max(stw))
counter = 0
for i in range(n):
	if stw[i] > mn and stw[i] < mx:
		counter += 1
print(counter)


import math
import sys

def ri():
	return input()

def ii():
	return int(input())

def li():
	return input().split()

def mi():
	return list(map(int, input().split()))
n = ii()
a = mi()
l = min(a)
m = max(a)
s = 0
for i in a:
	if l < i and m > i:
		s += 1
print(s)


n = int(input())
a = list(map(int, input().split()))
if n < 3:
	print(0)
else:
	c = 0
	m = min(a)
	b = max(a)
	for i in range(0, n):
		if a[i] == m or a[i] == b:
			c = c + 1
	print(n - c)


n = int(input())
a = list(map(int, input().split()))
minim = min(a)
maxim = max(a)
ans = 0
for i in a:
	if minim < i < maxim:
		ans += 1
print(ans)


num_array = list()
num = input()
num = int(num)
n = input()
mincount = 0
maxcount = 0
a = n.split()
for i in a:
	num_array.append(int(i))
sorted1 = sorted(num_array)
for i in sorted1:
	if sorted1[0] == i:
		mincount += 1
for value in reversed(sorted1):
	if sorted1[num - 1] == value:
		maxcount += 1
if num - (maxcount + mincount) < 0:
	output = 0
else:
	output = num - (maxcount + mincount)
print(output)


n = int(input())
stewards = list(map(int, input().split()))
counter = 0
mx = max(stewards)
mn = min(stewards)
if n <= 2:
	print(counter)
else:
	for i in range(n):
		if stewards[i] > mn and stewards[i] < mx:
			counter += 1
	print(counter)


n = int(input())
i = [int(x) for x in input().split()]
num_of_stewards = 0
max_num = max(i)
min_num = min(i)
for j in i:
	if j < max_num and j > min_num:
		num_of_stewards += 1
print(num_of_stewards)


n = int(input())
steward = list(map(int, input().split()))
mini = min(steward)
maxi = max(steward)
result = max(0, n - steward.count(mini) - steward.count(maxi))
print(result)


x = int(input())
l = list(map(int, input().split(' ')))
if min(l) == max(l):
	print(0)
else:
	print(x - l.count(min(l)) - l.count(max(l)))


n = input()
l = [int(x) for x in input().split()]
min = min(l)
max = max(l)
sol = 0
for i in l:
	if i != min and i != max:
		sol = sol + 1
print(sol)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	n = I()
	a = LI()
	c = collections.Counter(a)
	if len(c) < 3:
		return 0
	r = n
	r -= c[min(a)]
	r -= c[max(a)]
	return r
print(main())


arg = int(input())
l1 = list(map(int, input().strip().split()))
low = min(l1)
high = max(l1)
res = 0
for n in l1:
	if n > low and n < high:
		res += 1
print(res)


n = int(input())
a = list(map(int, input().split()))
a.sort()
minimum = a[0]
maximum = a[n - 1]
count = 0
for i in range(1, n):
	if a[i] > minimum and a[i] < maximum:
		count += 1
print(count)


n = input()
s = [int(s) for s in input().split()]
result = 0
mx = max(s)
mn = min(s)
for i in s:
	if mn < i < mx:
		result += 1
print(result)


n = int(input())
arr = list(map(int, input().split()))
maximum = arr[0]
minimum = arr[0]
for value in arr:
	if maximum < value:
		maximum = value
	if minimum > value:
		minimum = value
print(len([value for value in arr if value != minimum and value != maximum]))


_ = input()
n = list(map(int, input().rstrip().split()))
n.sort()
maxa = n[len(n) - 1]
mini = n[0]
c = 0
for i in n:
	if i > mini and i < maxa:
		c += 1
print(c)


n = int(input())
steward = sorted(list(map(int, input().split())))
support = 0
for i in range(0, n - 1):
	if steward[-1] > steward[i] > steward[0]:
		support += 1
print(support)


from collections import deque
from collections import Counter

def main():
	from sys import stdin
	lines = deque((line.strip() for line in stdin.readlines()))
	n = int(lines.popleft())
	nums = Counter((int(x) for x in lines.popleft().split()))
	(small, large) = (min(nums.keys()), max(nums.keys()))
	print(sum(nums.values()) - nums[small] - nums[large] if len(nums) > 2 else 0)
main()


n = int(input())
a = list(map(int, input().split()))
if n < 3:
	print(0)
elif max(a) == min(a):
	print(0)
else:
	print(n - a.count(max(a)) - a.count(min(a)))


length = int(input())
numbers = [int(i) for i in input().split()]
numbers.sort()
total = 0
for x in range(len(numbers)):
	if numbers[x] < numbers[-1] and numbers[x] > numbers[0]:
		total += 1
print(total)


def organize_stewards(stewards):
	return sorted(stewards)

def stewards_supported(stewards, nstewards):
	if nstewards <= 2:
		return 0
	stewards = organize_stewards(stewards)
	unsuported = (last_index_of_occurrence(stewards, stewards[0], 0, nstewards - 1), frist_index_of_occurrence(stewards, stewards[nstewards - 1], 0, nstewards - 1))
	if unsuported[1] == 0:
		return 0
	return unsuported[1] - unsuported[0] - 1

def frist_index_of_occurrence(l, target, start, end, result=None):
	if start > end:
		return result
	mid = (start + end) // 2
	if target == l[mid]:
		return frist_index_of_occurrence(l, target, start, mid - 1, mid)
	elif target < l[mid]:
		return frist_index_of_occurrence(l, target, start, mid - 1, result)
	else:
		return frist_index_of_occurrence(l, target, mid + 1, end, result)

def last_index_of_occurrence(l, target, start, end, result=None):
	if start > end:
		return result
	mid = (start + end) // 2
	if target == l[mid]:
		return last_index_of_occurrence(l, target, mid + 1, end, mid)
	elif target > l[mid]:
		return last_index_of_occurrence(l, target, mid + 1, end, result)
	else:
		return last_index_of_occurrence(l, target, start, mid - 1, result)
nstewards = int(input())
stewards = list(map(int, input().rstrip().split()))
print(stewards_supported(stewards, nstewards))


n = int(input())
a = list(map(int, input().split()))
mini = min(a)
maxi = max(a)
mini_count = 0
maxi_count = 0
for i in range(0, n):
	if a[i] == maxi:
		maxi_count += 1
	if a[i] == mini:
		mini_count += 1
if maxi == mini:
	print(0)
else:
	print(n - maxi_count - mini_count)


n = int(input())
w = list(map(int, input().split()))
x = min(w)
y = max(w)
c = 0
for i in range(n):
	if w[i] > x and w[i] < y:
		c += 1
print(c)


def is_there_odd(s):
	for i in range(len(s)):
		if not i % 2:
			if int(s[i]) % 2:
				return True
	return False

def is_there_even(s):
	for i in range(len(s)):
		if i % 2:
			if not int(s[i]) % 2:
				return True
	return False

def main_function():
	input()
	stewards = [int(i) for i in input().split(' ')]
	max_steward = max(stewards)
	min_steward = min(stewards)
	counter = 0
	for i in stewards:
		if i < max_steward and i > min_steward:
			counter += 1
	return counter
print(main_function())


def solution():
	n = int(input())
	stewards = [int(x) for x in input().split()]
	min_steward = min(stewards)
	max_steward = max(stewards)
	count = 0
	for steward in stewards:
		if min_steward < steward < max_steward:
			count += 1
	print(count)
solution()


input()
x = 0
stewards = sorted(map(int, input().split()))
for i in stewards:
	if i < stewards[-1] and i > stewards[0]:
		x += 1
print(x)


def oath(l):
	s = sorted(l)
	result = 0
	for i in l:
		if i > s[0] and i < s[-1]:
			result += 1
	print(result)
n = int(input())
l = [int(x) for x in input().split()]
oath(l)


n = int(input())
arr = list(map(int, input().split()))
arr.sort()
c = 0
for x in range(0, n):
	if arr[x] > arr[0] and arr[x] < arr[n - 1]:
		c += 1
print(c)


n = int(input())
a = list(map(int, input().split()))
m = min(a)
b = max(a)
k = 0
for i in a:
	if i == m or i == b:
		k += 1
print(n - k)


n = int(input())
l = sorted(list(map(int, input().split())))
if n <= 2:
	print('0')
elif len(set(l)) == 1:
	print('0')
else:
	a = l.count(l[0])
	b = l.count(l[-1])
	print(n - (a + b))


def ri():
	return map(int, input().split())
n = int(input())
a = list(ri())
a.sort()
ans = n
for i in range(n):
	if i < n - 1 and a[i] == a[i + 1]:
		ans -= 1
	else:
		ans -= 1
		break
for i in range(n - 1, -1, -1):
	if i >= 1 and a[i] == a[i - 1]:
		ans -= 1
	else:
		ans -= 1
		break
if ans < 0:
	print(0)
else:
	print(ans)


n = int(input())
s = input().split()
s = list(map(int, s))
ma = max(s)
mi = min(s)
index = [i for (i, x) in enumerate(s) if x == ma or x == mi]
p = len(s) - len(index)
print(p)


n = int(input())
l1 = list(map(int, input().split()))
l1.sort()
a = len(l1)
ans = 0
for i in range(0, a):
	if l1[i] == l1[0] or l1[i] == l1[a - 1]:
		ans += 0
	else:
		ans += 1
print(ans)


e = int(input())
stew = input().split(' ')
for i in range(len(stew)):
	stew[i] = int(stew[i])
stew.sort()
supported = 0
lowest = stew[0]
to_add = 0
to_add_val = -1
for i in range(len(stew)):
	if stew[i] > to_add_val:
		if to_add_val > lowest:
			supported += to_add
		to_add = 1
		to_add_val = stew[i]
	elif stew[i] == to_add_val:
		to_add += 1
print(supported)


n = int(input())
a = list(map(int, input().split()))
a.sort()
temp = a[0]
while a[0] == temp:
	del a[0]
	if len(a) == 0:
		break
if len(a) > 0:
	temp = a[-1]
	while a[-1] == temp:
		del a[-1]
		if len(a) == 0:
			break
print(len(a))


numOfPeople = int(input())
people = list(map(int, input().split()))
if numOfPeople == 1:
	print(0)
else:
	people = sorted(people)
	minNumber = people[0]
	maxNumber = people[-1]
	if minNumber == maxNumber:
		print(0)
	else:
		counter = 2
		i = 1
		while people[i] == minNumber:
			counter += 1
			i += 1
		i = -2
		while people[i] == maxNumber:
			counter += 1
			i -= 1
		print(numOfPeople - counter)


n = int(input())
l = list(map(int, input().split()))
l.sort()
mi = l[0]
ma = l[-1]
res = 0
for i in l:
	if mi < i < ma:
		res += 1
print(res)


n = int(input())
a = sorted(list(map(int, input().split())))
(first, last) = (a[0], a[-1])
print(len([x for x in a if x != last and x != first]))


n = int(input())
a = list(map(int, input().split()))
mn = min(a)
mx = max(a)
c = 0
for i in a:
	if i == mn or i == mx:
		c += 1
print(n - c)


n = int(input())
a = list(map(int, input().split()))
r = 0
min_a = min(a)
max_a = max(a)
for i in a:
	if i > min_a and i < max_a:
		r += 1
print(r)


n = int(input())
input1 = list(map(int, input().split()))
t = 0
min = min(input1)
max = max(input1)
for i in input1:
	if i > min and i < max:
		t += 1
print(t)


n = int(input())
a = list(map(int, input().split()))
mn = min(a)
mx = max(a)
ans = 0
for x in a:
	if x > mn and x < mx:
		ans += 1
print(ans)


n = int(input())
l = [int(x) for x in input().split()]
maxi = max(l)
mini = min(l)
count = 0
for x in l:
	if x < maxi and x > mini:
		count += 1
print(count)


input()
data = [int(x) for x in input().split()]
mins = min(data)
maxs = max(data)
print(len(list(filter(lambda x: x > mins and x < maxs, data))))


import sys
input = lambda : sys.stdin.readline().strip()
li = lambda : list(map(int, input().split()))
n = int(input())
l = li()
if len(set(l)) < 3:
	print(0)
	exit()
l.sort()
s = 0
e = n - 1
while l[s] == l[0]:
	s += 1
while l[e] == l[-1]:
	e -= 1
print(e - s + 1)


n = map(int, input().split())
a = list(map(int, input().split()))
a_max = max(a)
a_min = min(a)
cnt = 0
for a_i in a:
	if a_i != a_min and a_i != a_max:
		cnt += 1
print(cnt)


n = int(input())
s = [int(p) for p in input().split()]
s.sort()
cnt = 0
for st in s:
	if st > s[0] and st < s[-1]:
		cnt += 1
print(cnt)


n = int(input())
li = [int(x) for x in input().split()]
b = li.count(max(li))
s = li.count(min(li))
print(max(n - s - b, 0))


total = 0
numOfSecond = int(input())
splitInput = [int(a) for a in input().split()]
tmpMin = min(splitInput)
tmpMax = max(splitInput)
for i in range(numOfSecond):
	if tmpMin < splitInput[i] < tmpMax:
		total += 1
print(total)


input()
a = list(map(int, input().split()))
ma = max(a)
mi = min(a)
to_p = 0
for e in a:
	if e > mi and e < ma:
		to_p += 1
print(to_p)


n = int(input())
a = list(map(int, input().split()))
a.sort()
mini = min(a)
maxi = max(a)
(left, right) = (10000000000, 0)
for i in range(n):
	if a[i] != mini:
		left = i
		break
for i in range(n - 1, -1, -1):
	if a[i] != maxi:
		right = i
		break
print(max(right - left + 1, 0))


n = int(input())
L = [int(x) for x in input().split()]
L.sort()
ct = 0
for x in L:
	if x != L[0] and x != L[-1]:
		ct += 1
print(ct)


import sys
n = int(input())
an = list(map(int, sys.stdin.readline().split()))
an.sort()
ans = n
first = 1
while first < n and an[first] == an[0]:
	first += 1
last = n - 2
while last > 0 and an[last] == an[n - 1]:
	last -= 1
if first <= last:
	ans = last - first + 1
else:
	ans = 0
print(ans)


from collections import Counter
gi = lambda : list(map(int, input().split()))
(n,) = gi()
l = gi()
occ = Counter(l)
print(max(n - occ[max(l)] - occ[min(l)], 0))


n = int(input())
a = input().split()
bb = []
for i in a:
	i = int(i)
	bb.append(i)
max_bb = max(bb)
min_bb = min(bb)
count = 0
for i in bb:
	if i > min_bb and i < max_bb:
		count = count + 1
print(count)


n = int(input())
if n <= 2:
	print(0)
	exit(0)
arr = sorted(list(map(int, input().split(' '))))
(i, j) = (1, n - 2)
while i < n - 1:
	if arr[i] != arr[i - 1]:
		break
	i += 1
while j >= i:
	if arr[j] != arr[j + 1]:
		break
	j -= 1
print(max(j - i + 1, 0))


n = int(input())
t = [int(i) for i in input().split()]
(s, mn, mx) = (0, min(t), max(t))
for x in t:
	if mn < x < mx:
		s += 1
print(s)


ln = int(input())
lst = list(map(int, input().split(' ')))
slst = sorted(lst)
cnt = 0
for each in slst:
	if each > slst[0] and each < slst[-1]:
		cnt += 1
print(cnt)


n = int(input())
l = [int(c) for c in input().split()]
if len(set(l)) == 1:
	print(0)
else:
	mi = min(l)
	mx = max(l)
	ci = l.count(mi)
	cm = l.count(mx)
	print(len(l) - ci - cm)


n = int(input())
nums = [int(num) for num in input().split()]
maxN = max(nums)
minN = min(nums)
sumN = 0
for num in nums:
	if num < maxN and num > minN:
		sumN += 1
print(sumN)