n = int(input())

l = [ int(i) for i in input().split(" ") ]

even = [ i for i in l if i % 2 == 0 ]
odd = [ i for i in l if i % 2 != 0 ]

n_even = len(even)
n_odd = len(odd)

if n_even > n_odd:
    # start from even
    n_even -= n_odd + 1
    n_odd = 0
else:
    # start from odd
    n_odd -= n_even + 1
    n_even = 0

if n_even < 0:
    n_even = 0
if n_odd < 0:
    n_odd = 0

even.sort()
odd.sort()

rem_sum = sum(even[:n_even]) + sum(odd[:n_odd])

print(rem_sum)