input()
n=list(map(int, input().split()))
e=[]
o=[]
for i in n:
   if i%2==1:
       o.append(i)
   else:
       e.append(i)

o.sort(reverse=True)
e.sort(reverse=True)
if len(o)>len(e):
    print(sum(o[len(e)+1:]))
else:
    print(sum(e[len(o)+1:]))