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