t=int(raw_input())
a=map(int,raw_input().split())
even=[0]
odd=[0]
n1,n2=1,1
a.sort()
for i in a:
    if i&1:
        odd.append(i)
        n1+=1
    else:
        even.append(i)
        n2+=1
if n1>n2 or (n2==n1 and odd[n1-1]>even[n2-1]):
    even,odd=list(odd),list(even)
    n1,n2=n2,n1
while n1>1 and n2>1:
    even.pop()
    odd.pop()
    n1,n2=n1-1,n2-1
if n2>1:
    even.pop()
print sum(even+odd)