n = int(input())
a = list(map(int, input().split()))
even = [i for i in a if i % 2 == 0]
odd = [i for i in a if i % 2 != 0]
even.sort()
odd.sort()
elen = len(even)
olen = len(odd)
if elen == olen + 1 or elen + 1 == olen or elen == olen:
    print(0)
else:
    m = min(elen, olen)
    s = 0
    if m == elen:
        for i in range(olen - m - 1):
            s += odd[i]        
    else:
        for i in range(elen - m - 1):
            s += even[i]
    print(s)