n = int(raw_input())
lis = map(int, raw_input().split())
lol1 = []
lol2 = []
for i in lis:
    if i%2==0:
        lol2.append(i)
    else:
        lol1.append(i)
lol1 = sorted(lol1)
lol2 = sorted(lol2)
if len(lol1) == len(lol2) or abs(len(lol2)-len(lol1)) == 1:
    print 0
else:
    sum = 0
    if len(lol1) == 0:
        for i in xrange(len(lol2)-1):
            sum += lol2[i]
        print sum
    elif len(lol2) == 0:
        for i in xrange(len(lol1)-1):
            sum += lol1[i]
        print sum
    elif len(lol1) < len(lol2):
        for i in xrange(len(lol2)-len(lol1)):
            sum += lol2[i]
        print sum
    else:
        for i in xrange(len(lol1)-len(lol2)):
            sum += lol1[i]
        print sum
