n = int(input())
a = list(map(int,input().split()))
ch = []
nech = []
for i in a:
    if i%2==0:
        ch.append(i)
    else:
        nech.append(i)
ch.sort()
nech.sort()
beg = len(ch)>len(nech)
while len(ch)>0 and len(nech)>0:
    if beg:
        ch.pop()
        nech.pop()
    else:
        nech.pop()
        ch.pop()
if beg:
    ch.pop()
else:
    if len(nech)>0:
        nech.pop()
print(sum(ch)+sum(nech))