n = int(input())
a = list(map(int, input().split()))
s = sum(a)
ch = [[], []]
for i in a:
    ch[i % 2].append(i)

ch[0].sort(reverse=True)
ch[1].sort(reverse=True)
if len(ch[0]) >= len(ch[1]):
    s -= sum(ch[1])
    s -= sum(ch[0][:len(ch[1])])
    if len(ch[0]) != len(ch[1]):
        s -= ch[0][len(ch[1])]
else:
    s -= sum(ch[0])
    s -= sum(ch[1][:len(ch[0]) + 1])
print(s)
