n=int(input())
a=[int(x) for x in input().split()]
ev=[]
od=[]
for i in a:
    if i%2==0:
        ev.append(i)
    else:
        od.append(i)
ev.sort(reverse=True)
od.sort(reverse=True)
m=len(ev)
n=len(od)

ans=0
if m>n:
    i=0
    del ev[0]
    for i in range(n):
        del ev[0]
        del od[0]
elif m<n:
    del od[0]
    for i in range(m):
        del od[0]
        del ev[0]
else:
    for i in range(n):
        del od[0]
        del ev[0]        
print(sum(ev)+sum(od))
        
