def f(a, b):
    z = []
    i, j = 0, 0
    while i < len(a) and j < len(b):
        z.append(a[i])
        z.append(b[j])
        i+=1
        j+=1
    while i < len(a):
        z.append(a[i])
        i+=1
    while j < len(b):
        z.append(b[j])
        j+=1
    
    # print z
    ii = 1
    while ii < len(z):
        if (z[ii] & 1 and z[ii-1] % 2 == 0) or (z[ii] %2 ==0 and z[ii-1] & 1): 
            ii += 1
            continue
        break;
        
    return sum(z[ii:])

n = input()
A = map(int, raw_input().split())
odd = []
even = []
for ii in A:
    if ii & 1: odd.append(ii)
    else: even.append(ii)
odd.sort()
even.sort()

print min(f(odd, even), f(even, odd))