n=int(input())
x=list(map(int,input().split()))
y=[]
z=[]
for i in range(n):
    if x[i]%2==0:
        y.append(x[i])
    else:
        z.append(x[i])
y.sort(reverse=True)
z.sort(reverse=True)
if len(y)>len(z):
    y=y[(len(z)+1):]
    print(sum(y))
else:
    z=z[(len(y)+1):]
    print(sum(z))

