n = int(input())
s = input().split()
s = list(map(int, s))
s.sort()
even = []
odd = []

for i in range(n):
    if(s[i]%2==0):
        even.append(s[i])
    else:
        odd.append(s[i])
sum = 0
#if(abs(len(even) - len(odd)) == 1.0):
#    print(0)
if(len(even)>len(odd)+1):
    for i in range(len(even)-len(odd)-1):
        sum += even[i]
elif(len(odd)>len(even)+1):
    for i in range(len(odd)-len(even)-1):
        sum += odd[i]
        
print(sum)