import sys
sys.setrecursionlimit(10 ** 6)
# pow(3,2,5)==4

inp=input()
inp2=map(int,raw_input().split())
O=[]
E=[]
sum=0
for i in inp2:
    sum+=i
    if i%2:
        O.append(i)
    else:
        E.append(i)
O.sort()
E.sort()

mn=1e9
state=0
while (state==1 and O) or (state==0 and E):
    if state:
        sum-=O[-1]
        del O[-1]
    else:
        sum-=E[-1]
        del E[-1]
    state=state^1
mn=min(sum,min)
O=[]
E=[]
sum=0
for i in inp2:
    sum+=i
    if i%2:
        O.append(i)
    else:
        E.append(i)
# print mn
O.sort()
E.sort()
state=1
while (state==1 and O) or (state==0 and E):
    if state:
        sum-=O[-1]
        del O[-1]
    else:
        sum-=E[-1]
        del E[-1]
    state=state^1
mn=min(sum,mn)
print mn
