Sum all the numbers of the array (in F# and Haskell you get a list) except the highest and the lowest element (the value, not the index!).
(The highest/lowest element is respectively only one element at each edge, even if there are more than one with the same value!)
Example:
```
{ 6, 2, 1, 8, 10 } => 16
{ 1, 1, 11, 2, 3 } => 6
```


If array is empty, null or None, or if only 1 Element exists, return 0.
Note:In C++ instead null an empty vector is used. In C there is no null. ;-)




Have fun coding it and please don't forget to vote and rank this kata! :-) 

I have created other katas. Have a look if you like coding and challenges.

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Starter code: def sum_array(arr):
	

Solutions:
def sum_array(arr):
	if arr == None or len(arr) < 3:
		return 0
	return sum(arr) - max(arr) - min(arr)


def sum_array(arr):
	return sum(sorted(arr)[1:-1]) if arr and len(arr) > 1 else 0


def sum_array(arr):
	return sum(sorted(arr)[1:-1]) if arr else 0


def sum_array(arr):
	return sum(arr) - min(arr) - max(arr) if arr and len(arr) > 1 else 0


def sum_array(arr):
	return sum(sorted(arr or [])[1:-1])


def sum_array(arr):
	if arr is None or len(arr) < 2:
		return 0
	(mi, ma, s) = (arr[0], arr[0], 0)
	for x in arr:
		if x > ma:
			ma = x
		elif x < mi:
			mi = x
		s += x
	return s - mi - ma


def sum_array(arr):
	try:
		return sum(arr) - max(*arr) - min(*arr)
	except:
		return 0


sum_array = lambda a: a and sum(sorted(a)[1:-1]) or 0


def sum_array(arr):
	if len(arr or []) <= 2:
		return 0
	odd = len(arr) % 2
	if odd:
		total = lowest = highest = arr[0]
	else:
		(total, lowest, highest) = (0, float('inf'), -float('inf'))
	for (a, b) in zip(arr[odd::2], arr[1 + odd::2]):
		total += a + b
		if a > b:
			lowest = min(b, lowest)
			highest = max(a, highest)
		else:
			lowest = min(a, lowest)
			highest = max(b, highest)
	return total - lowest - highest


def sum_array(arr):
	return 0 if arr is None else sum(sorted(arr)[1:-1])


def sum_array(arr):
	if not arr or len(arr) == 1:
		return 0
	else:
		return sum(arr) - min(arr) - max(arr)


def sum_array(arr):
	if arr == [] or arr == None or len(arr) <= 2:
		return 0
	else:
		sum = 0
		arr.sort(reverse=False)
		for i in arr:
			sum += i
		return sum - int(arr[0] + arr[-1])


from functools import reduce
min_max_tot = lambda x, y: (min(x[0], y), max(x[1], y), x[2] + y)

def sum_array(arr):
	if arr is None or len(arr) < 3:
		return 0
	(mini, maxi, tot) = reduce(min_max_tot, arr, (float('inf'), float('-inf'), 0))
	return tot - mini - maxi


def sum_array(arr):
	if arr is None or len(arr) == 1:
		return 0
	arr = sorted(arr)
	return sum(arr[1:-1])


def sum_array(arr):
	if arr is None or len(arr) < 2:
		return 0
	lowest = min(arr)
	highest = max(arr)
	sum = 0
	for x in arr:
		sum += x
	return sum - lowest - highest


def sum_array(arr):
	return 0 if not arr or len(arr) <= 1 else sum(sorted(arr)[1:-1])


def sum_array(arr):
	return 0 if arr == None or len(arr) < 2 else sum(arr) - min(arr) - max(arr)


def sum_array(arr):
	if arr == None:
		return 0
	return sum(sorted(arr)[1:-1]) if len(arr) > 2 else 0


def max_value(a):
	high = a[1]
	for x in range(len(a)):
		for y in range(x + 1, len(a)):
			if a[x] > a[y] and a[x] > high:
				high = a[x]
				continue
			elif a[x] < a[y] and a[x] > high:
				high = a[y]
			else:
				continue
	if a[len(a) - 1] > high:
		return a[len(a) - 1]
	else:
		return high

def min_value(a):
	min = a[1]
	for x in range(len(a)):
		for y in range(x + 1, len(a)):
			if a[x] < a[y] and a[x] < min:
				min = a[x]
				continue
			elif a[x] > a[y] and a[x] < min:
				min = a[y]
			else:
				continue
	if a[len(a) - 1] < min:
		return a[len(a) - 1]
	else:
		return min

def sum_array(arr):
	total = 0
	max_occ = 0
	min_occ = 0
	if not arr:
		return 0
	elif len(arr) == 1:
		return 0
	else:
		for i in range(len(arr)):
			if arr[i] == max_value(arr) and max_occ == 0:
				max_occ = 1
				continue
			if arr[i] == min_value(arr) and min_occ == 0:
				min_occ = 1
				continue
			total = total + arr[i]
	return total


def sum_array(arr):
	return 0 if type(arr) is not list or len(arr) in (0, 1) else sum(arr) - max(arr) - min(arr)


sum_array = lambda a: sum(sorted(a)[1:-1]) if a else 0


def sum_array(arr):
	if not arr or len(arr) <= 2:
		return 0
	else:
		arr.sort()
		return sum(arr[1:-1])


def sum_array(arr):
	if arr == None:
		return 0
	if len(arr) <= 2:
		return 0
	else:
		arr.sort()
		del arr[0]
		del arr[-1]
		return sum(arr)


sum_good = lambda x: sum(x) - min(x) - max(x) * bool(x[1:])
sum_array = lambda arr: sum_good(arr or [0])


def sum_array(arr):

	def sum_array_(x):
		return sum(x) - min(x) - max(x) * bool(x[1:])
	return sum_array_(arr or [0])


def validation(foo):

	def wrapper(x):
		return foo(x or [0])
	return wrapper

@validation
def sum_array(x):
	return sum(x) - min(x) - max(x) * bool(x[1:])


def sum_array(arr):
	if arr is None or len(arr) <= 1:
		return 0
	print(sum(arr))
	return sum(arr) - max(arr) - min(arr)


def sum_array(arr):
	return 0 if arr is None or len(arr) in [0, 1] else sum(arr) - min(arr) - max(arr)


def sum_array(arr):
	if arr == None or arr == [] or len(arr) == 1:
		return 0
	else:
		return sum((x for x in arr)) - min(arr) - max(arr)


def sum_array(arr):
	if arr == None or len(arr) < 2:
		return 0
	arr = sorted(arr)
	arr.pop(0)
	arr.pop(-1)
	return sum(arr)


def sum_array(arr):
	if arr == None or arr == [] or len(arr) < 2:
		return 0
	else:
		lowest = arr[0]
		for i in arr:
			if i < lowest:
				lowest = i
		highest = arr[0]
		for i in arr:
			if i > highest:
				highest = i
		tot = 0
		for i in arr:
			tot += i
		return tot - lowest - highest


def sum_array(arr):
	if arr == None:
		return 0
	elif arr == []:
		return 0
	else:
		a = max(arr)
		b = min(arr)
		print(a)
		arr.remove(a)
		if arr == []:
			return 0
		else:
			total = 0
			arr.remove(b)
			for i in arr:
				total += i
			return total


def sum_array(arr):
	if arr == [] or arr == None:
		return 0
	elif len(arr) < 3:
		return 0
	arr = sorted(arr)
	result = 0
	arr.pop()
	arr.pop(0)
	print(arr)
	for i in arr:
		result += i
	return result


def sum_array(arr):
	if not arr:
		return 0
	if len(arr) < 3:
		return 0
	return sum(sorted(arr)[1:len(arr) - 1])


def sum_array(arr):
	if arr is None:
		return 0
	elif len(arr) <= 1:
		return 0
	a = max(arr)
	b = min(arr)
	c = sum(arr)
	return c - a - b


def sum_array(arr):
	if arr is None:
		return 0
	for el in arr:
		if type(el) == int and type(el) != 'NoneType' and (len(arr) > 2):
			arr.remove(max(arr))
			arr.remove(min(arr))
			print(arr)
			return sum(arr)
		else:
			return 0
	return sum(arr)


def sum_array(arr={}):
	if arr == None or arr == []:
		return 0
	if len(arr) > 1:
		res = sum(arr) - min(arr)
	else:
		res = sum(arr)
	return res - max(arr)


def sum_array(arr):
	if arr == None:
		return 0
	elif len(arr) == 0:
		return 0
	elif len(arr) == 1:
		return 0
	else:
		arr.remove(max(arr))
		arr.remove(min(arr))
		return sum(arr)


def sum_array(arr):
	if arr == None:
		return 0
	elif len(arr) == 1:
		return 0
	else:
		sorted_arr = sorted(arr)
		return sum(sorted_arr[1:-1])


def sum_array(arr):
	sum = 0
	if arr == '':
		return 0
	elif arr == None:
		return 0
	elif len(arr) < 3:
		return 0
	else:
		for i in arr:
			sum += i
		return sum - (min(arr) + max(arr))


sum_array = lambda a: 0 if a == None or len(a) < 2 else sum(a) - max(a) - min(a)


def sum_array(arr):
	try:
		if len(arr) == 1:
			return 0
		return sum(arr) - max(arr) - min(arr)
	except:
		return 0


def sum_array(arr):
	total = 0
	if not arr:
		return 0
	elif len(arr) <= 2:
		return 0
	else:
		for number in range(0, len(arr)):
			total += arr[number]
			print(total)
		return total - min(arr) - max(arr)


def sum_array(arr):
	if not arr:
		return 0
	arr.remove(max(arr))
	if not arr:
		return 0
	arr.remove(min(arr))
	return sum(arr)


def sum_array(arr):
	if not arr:
		return 0
	arr2 = []
	arr.sort()
	index = -1
	for i in arr:
		index += 1
		if index > 0 and index < len(arr) - 1:
			arr2.append(i)
	return sum(arr2)


def sum_array(arr):
	if arr == None:
		return 0
	elif len(arr) == 1:
		return 0
	elif arr == []:
		return 0
	else:
		somme = 0
		for elements in arr:
			somme += elements
		somme = somme - min(arr) - max(arr)
		return somme


def sum_array(arr):
	if hasattr(arr, 'sort'):
		arr.sort()
		return sum(arr[1:-1], 0)
	else:
		return 0


def sum_array(arr):
	sum = 0
	if not arr or len(arr) == 1:
		return 0
	else:
		for i in arr:
			sum = sum + i
		return sum - min(arr) - max(arr)


def sum_array(a):
	try:
		a.sort()
		a = sum(a[1:-1])
	except AttributeError:
		a = 0
	return a


def sum_array(arr):
	if not arr or len(arr) in [1, 2]:
		return 0
	(maxn, minn, sumn) = (arr[0], arr[0], 0)
	for n in arr:
		if n > maxn:
			maxn = n
		elif n < minn:
			minn = n
		sumn += n
	return sumn - maxn - minn


def sum_array(arr):
	if not arr:
		return 0
	else:
		res = sorted(arr)[1:-1]
		return sum((i for i in res))


def sum_array(arr):
	if arr == [] or arr == None or len(arr) == 1:
		return 0
	else:
		mini = min(arr)
		maxi = max(arr)
		max_index = arr.index(maxi)
		min_index = arr.index(mini)
		arr[max_index] = 0
		arr[min_index] = 0
		ttl = 0
		for x in arr:
			ttl += x
	return ttl


def sum_array(arr):
	sum = 0
	if arr == None or len(arr) < 3:
		return sum
	arr.sort()
	for i in range(1, len(arr) - 1):
		sum += arr[i]
	return sum


def sum_array(arr):
	if arr == None:
		return 0
	elif len(arr) <= 2:
		return 0
	arr.sort()
	return sum(arr[1:-1])


def sum_array(arr):
	if arr == None or arr == []:
		return 0
	mi = min(arr)
	ma = max(arr)
	st = (arr.count(mi) - 1) * mi + (arr.count(ma) - 1) * ma
	for i in arr:
		if i not in [mi, ma]:
			st += i
	return st


def sum_array(arr):
	if not arr:
		return 0
	(c, y) = (0, [])
	for x in arr:
		if c < 2 and (x == max(arr) or x == min(arr)):
			c += 1
		else:
			y.append(x)
	return sum(y)


def sum_array(arr):
	if arr and len(arr) > 2:
		arr.pop(arr.index(max(arr)))
		arr.pop(arr.index(min(arr)))
	else:
		return 0
	return sum(arr)


def sum_array(arr):
	try:
		print(sorted(arr))
		print(sorted(arr)[1:-1])
		return sum(sorted(arr)[1:-1]) if len(arr) > 2 else 0
	except TypeError:
		return 0


def sum_array(arr):
	sum = 0
	if arr == None or arr == []:
		return 0
	else:
		new = sorted(arr)
	for i in range(1, len(new) - 1):
		sum += new[i]
	return sum


def sum_array(arr):
	if arr is None or len(arr) < 3:
		return 0
	else:
		arr.sort()
		return sum(arr) - arr[0] - arr[-1]


def sum_array(arr):
	if not arr or len(arr) == 1:
		return 0
	total = mn = mx = arr[0]
	for x in arr[1:]:
		total += x
		if x < mn:
			mn = x
		if x > mx:
			mx = x
	return total - mn - mx


def sum_array(arr):
	a = 0
	if arr == []:
		return 0
	if arr == None:
		return 0
	if len(arr) == 1 or len(arr) == 2:
		return 0
	arr.sort()
	for i in range(len(arr) - 2):
		a += arr[i + 1]
	return a


def sum_array(arr):
	try:
		if len(arr) > 2:
			arr.sort()
			return sum(arr[1:-1])
		else:
			return 0
	except TypeError:
		return 0


def sum_array(arr):
	print(arr)
	if not arr:
		return 0
	elif len(arr) == 1:
		return 0
	else:
		sum = 0
		x = 0
		for x in arr:
			sum += x
		return sum - max(arr) - min(arr)


def sum_array(arr):
	if arr and len(arr) > 3:
		return sum(arr) - min(arr) - max(arr)
	return 0


def sum_array(arr: list):
	if arr is None or len(arr) <= 2:
		return 0
	sorted_arr = sorted(arr)
	return sum(sorted_arr[1:-1])


def sum_array(arr):
	if not arr:
		return 0
	if len(arr) == 1:
		return 0
	if len(arr) == 2:
		return 0
	return sum(sorted(arr)[1:-1])


def sum_array(arr):
	if arr == None or arr == []:
		return 0
	for x in arr:
		if int(len(arr)) >= 3:
			return int(sum(arr) - min(arr) - max(arr))
		else:
			return 0


def sum_array(arr):
	if arr == None:
		return False
	elif len(arr) == 1 or len(arr) == 0:
		return 0
	sum = 0
	minimum = min(arr)
	maximum = max(arr)
	for i in arr:
		sum += i
	return sum - minimum - maximum


def sum_array(arr):
	try:
		l = arr.remove(min(arr))
		l = arr.remove(max(arr))
		return sum(arr)
	except:
		return 0


def sum_array(arr):
	if arr == None:
		return 0
	if len(arr) == 0:
		return 0
	sum = 0
	arr.sort()
	w = arr[1:-1]
	for i in w:
		sum += i
	return sum


def sum_array(arr):
	if arr == None:
		return 0
	else:
		list.sort(arr)
		sum = 0
		length = len(arr)
		if 1 >= length:
			return sum
		else:
			array = arr
			array = array[1:len(array) - 1]
			for x in array:
				sum += x
			return sum


def sum_array(arr=[0]):
	try:
		if len(arr) > -1 and len(arr) < 3:
			return 0
		else:
			return sum(arr) - (min(arr) + max(arr))
	except:
		return 0


def sum_array(numbers):
	return bool(numbers) and sum(sorted(numbers)[1:-1])