n=int(input())
n1 = list(map(int,input().split()))
oddlist=[]
evenlist=[]
for i in n1:
    if i%2==0:
        evenlist.append(i)
    else:
        oddlist.append(i)
evenlist.sort()
oddlist.sort()
a1=len(evenlist)
b1=len(oddlist)
if a1>b1:
    index=a1-b1-1
    sumo=0
    for i in range(index):
        sumo+=evenlist[i]
elif b1>a1:
    index = b1 - a1 - 1
    sumo = 0
    for i in range(index):
        sumo += oddlist[i]
else:
    sumo=0

print(sumo)



