from math import fabs
a = int(input())
a = [int(i) for i in input().split()]

b = list(filter(lambda x: x % 2 == 0, a))
c = list(filter(lambda x: x % 2 == 1, a))

lb = len(b)
lc = len(c)

if lb == lc or fabs(lb - lc) == 1:
    print(0)
elif lb > lc:
    b = sorted(b)
    print(sum(b[0:(lb - lc - 1)]))
else:
    c = sorted(c)
    print(sum(c[0:(lc - lb - 1)]))
    
    
    
    
    
