n = int(input())
a = list(map(int, input().split(" ")))
a = sorted(a, reverse=True)
odd = []
even = []
res = sum(a)
for i in range(n):
    if a[i] % 2 == 1:
        odd.append(a[i])
    else:
        even.append(a[i])
if len(odd) == len(even):
    res = 0
else:
    if len(odd) < len(even):
        res -= sum(odd)
        res -= sum(even[:len(odd)+1])
    else:
        res -= sum(even)
        res -= sum(odd[:len(even)+1])
print(res)
    