#####################################   
import atexit, io, sys, collections, math, heapq, fractions, bisect,copy
buffer = io.BytesIO() 
sys.stdout = buffer
@atexit.register 
def write(): sys.__stdout__.write(buffer.getvalue())   
#####################################




def f(cc):
	if abs(len(cc[0]) - len(cc[1])) <= 1:
		return 0
	q0 = sorted(cc[0])#.#sort()
	q1 = sorted(cc[1])#.sort()
	if len(q0) < len(q1):
		q0,q1 = q1,q0
	return sum(q0[:-len(q1)- 1] or [0])

cc = collections.defaultdict(list)
n = int(raw_input())
for u in map(int, raw_input().split()):
	cc[u%2].append(u)
print f(cc)