#cook your dish here
def show(t):
    a = list(map(int,input().rstrip().split()))
    e = 0
    o = 0
    ea = []
    oa = []
    a.sort(reverse=True)
    for i in a:
        if (i & 1)==0:
            e = e + i
            ea.append(i)
        else:
            o = o + i
            oa.append(i)
    if e>o:
        c=0
        for i in range(t):
            if c==0 and len(ea)!=0:
                a.remove(max(ea))
                ea.remove(max(ea))
                c=1
            elif c==1 and len(oa)!=0:
                c=0
                a.remove(max(oa))
                oa.remove(max(oa))
            elif len(ea)==0 or len(oa)==0:
                break
    else:
        c=1
        for i in range(t):
            if c==0 and len(ea)!=0:
                a.remove(max(ea))
                ea.remove(max(ea))
                c=1
            elif c==1 and len(oa)!=0:
                c=0
                a.remove(max(oa))
                oa.remove(max(oa))
            elif len(ea)==0 or len(oa)==0:
                break
    print(sum(a))
show(int(input()))