n = int(raw_input())
l = map(int,raw_input().split())
def rdc(lst):
    return lst%2
q = map(rdc,l)
s = sorted(l)
od = q.count(1)
ev = q.count(0)
rem = abs(od-ev)-1
if rem < 0:
    rem = 0
fin = 0
z = 0
if od > ev:
    if n ==2:
        fin = s
    else:    
        for i in s:
            while z < rem:
                if i%2==1:
                    fin+=i
                z+=1
elif ev > od:
    if n == 2:
        fin = s[0]
    else:
        for i in s:
            while z < rem:
                if i%2==0:
                    fin+=i
                z+=1
print fin