n=int(input())
a=list(map(int,input().split()))
even=[]
odd=[]
for i in range(0,len(a)):
    if a[i]%2==0:
        even.append(a[i])
    else:
        odd.append(a[i])
even.sort()
odd.sort()
if abs(len(even)-len(odd))<=1:
    print(0)
else:
    if len(even)>len(odd):
        p=len(even)-len(odd)
        print(sum(even[:p-1]))
    else:
        p=len(odd)-len(even)
        print(sum(odd[:p-1]))