n=int(input())
ar = list(map(int, input().strip().split(' ')))
lst1=[]
lst2=[]
for i in range(n):
    if ar[i]%2==0:
        lst2.append(ar[i])
    else:
        lst1.append(ar[i])
lst1.sort(reverse=True)
lst2.sort(reverse=True)
n1=len(lst1)
n2=len(lst2)

if n1==n2 or n1==n2+1 or n2==n1+1:
    print('0')
else:
    if n1>n2:
        a=n2+1
        s=sum(lst1[a:])
    else:
        a=n1+1
        s=sum(lst2[a:])
    print(s)
        
        
        
    