n=int(input())
lst=list(map(int,input().split()))
a,b,len1,len2=[],[],0,0
for i,x in enumerate(lst):
    if x%2==0:a.append(x);len1+=1
    else:b.append(x);len2+=1
a.sort();a.reverse()
b.sort();b.reverse()
if len1<len2:print(sum(b[len1+1:]))
else:print(sum(a[len2+1:]))