input()
a=[[],[]]
for x in map(int,input().split()):a[x%2]+=[x]
m,n=map(len,a)
k=min(m,n)
for i in[0,1]:a[i].sort(reverse=True)
print(sum(a[0]+a[1])-sum(a[0][:k])-sum(a[1][:k])-(a[[0,1][n>k]]+[0])[k]*(m!=n))