from sys import stdin
#t = int(stdin.readline())
t = 1
for _ in xrange(t):
    n = int(stdin.readline())
    a = map(int,stdin.readline().split())
    ev = []
    od = []
    for i in a:
        if i%2:
            od.append(i)
        else:
            ev.append(i)
    od.sort()
    ev.sort()
    n = len(od)
    m = len(ev)
    if n > m+1:
        print sum(od[:n-m-1])
    elif m>n+1:
        print sum(ev[:m-n-1])
    else:
        print 0