n = int(input())
li = [int(x) for x in input().split()]
li.sort()
ev_li = []
od_li = []
for i in range(n):
    if(li[i] % 2 == 0):
        ev_li.append(li[i])
    else:
        od_li.append(li[i])
l1 = len(ev_li)
l2 = len(od_li)
diff = abs(l1-l2)
sum = 0
if(l1 > l2):
    if(diff > 1):
        for k in range(diff-1):
            sum = sum + ev_li[k]
else:
    if(diff > 1):
        for k in range(diff-1):
            sum = sum + od_li[k]
print(sum)