import sys,math
from fractions import gcd
import heapq
from collections import defaultdict
from io import BytesIO
sys.stdin = BytesIO(sys.stdin.read())
input = lambda: sys.stdin.readline().rstrip('\r\n')
n = int(input())
#n,k = [int(x) for x in input().split(' ')]
arr = [int(x) for x in input().split(' ')]
#st = input()
ch = []
nech = []
for el in arr:
    if el % 2:
        nech.append(el)
    else:
        ch.append(el)

ch.sort()
nech.sort()
if -1 <= len(ch) - len(nech) <= 1:
    print(0)
    exit()
if len(ch) > len(nech):
    arr = ch[:-len(nech)-1]
else:
    arr = nech[:-len(ch)-1]
print(sum(arr))
    
    