int(input())
a=list(map(int,input().split(" ")))
b=list(filter(lambda x:x%2==0,a))
b.sort(reverse=True)
c=list(filter(lambda x:x%2!=0,a))
c.sort(reverse=True)
if abs(len(b)-len(c))<=1:
    print (0)
else:
    if len(b)<len(c):
        b,c=c,b
    b.sort()
    s=0
    for i in range(0,len(b)-len(c)-1):
        s+=b[i]
    print (s)
        