import atexit
import io
import sys

buff = io.BytesIO()
sys.stdout = buff


@atexit.register
def write():
    sys.__stdout__.write(buff.getvalue())

n = input()
l = map(int, raw_input().split())
odd = []
even = []
for a in l:
	if a&1:
		odd.append(a)
	else:
		even.append(a)
odd.sort(reverse = True)
even.sort(reverse = True)
ptr1 = 0
ptr2 = 0
ans1 = 0
ans2 = 0
cnt = 0
while ptr1 <= len(odd) and ptr2 <= len(even):
	if cnt&1:
		if ptr1 == len(odd):
			break
		ptr1 += 1
	else:
		if ptr2 == len(even):
			break
		ptr2 += 1
	cnt += 1
ans1 = sum(odd[ptr1:]) + sum(even[ptr2:])
cnt = 0
ptr1 = 0
ptr2 = 0
while ptr1 <= len(odd) and ptr2 <= len(even):
	if cnt&1:
		if ptr2 == len(even):
			break
		ptr2 += 1
	else:
		if ptr1 == len(odd):
			break
		ptr1 += 1
	cnt += 1
ans2 = sum(odd[ptr1:]) + sum(even[ptr2:])
print min(ans1, ans2)