from math import fabs

b = input()
a = raw_input()
s = []
s = a.split(' ')
sum_c = 0
sum_n = 0
result = 0
end = 0
raznica = 0
mas_n = []
mas_c = []
for number in s:
    if (int(number)%2==0):
        sum_c = sum_c + 1
        mas_c.append(int(number))
    else:
        sum_n = sum_n + 1
        mas_n.append(int(number))
if(sum_c == sum_n):
    end = end + 1
elif(fabs(sum_c - sum_n) == 1.0):
    end = end + 1
else:
    raznica = fabs(sum_c - sum_n) - 1
    if (sum_c > sum_n):
        mas_c = sorted(mas_c)
        sw = 0
        for nu in mas_c:
            if(sw < raznica):
                result=result+nu
            else:
                break
            sw = sw + 1
    else:
        mas_n = sorted(mas_n )
        sw = 0
        for nu in mas_n:
            if (sw < raznica):
                result = result + nu
            else:
                break
            sw = sw + 1
print(result)

