n = int(input())
lst = sorted(list(map(int,input().split())),reverse = True)
even = odd = 0
for i in range(n):
    if lst[i]&1 == 1:
        odd += 1
    else:
        even += 1
if even > odd:
    even = odd + 1
elif odd > even:
    odd = even + 1

for i in range(n):
    if lst[i]&1 == 1 and odd > 0:
        odd -= 1
        lst[i] = 0
    elif lst[i]&1 == 0 and even > 0:
        even -= 1
        lst[i] = 0
    if even == 0 and odd == 0:
        break
print(sum(lst))
