n=int(input())
a=list(map(int,input().split()))
a1=[]
a2=[]

for i in range (n):
    if(a[i]%2==0):
        a1.append(a[i])
    else:
        a2.append(a[i])

a1.sort()
a2.sort()
x=len(a1)
y=len(a2)

su=0
if(x>y):
    for i in range (0,(x-y-1)):
        su+=a1[i]

elif(x<y):
    for i in range (0,(y-x-1)):
        su+=a2[i]

print(su)