n = int(input())
l = [*map(int, input().split())]
odd = []
even = []

for i in l:
    if i%2: odd.append(i)
    else: even.append(i)

odd.sort()
even.sort()

while odd and even:
    odd.pop()
    even.pop()

res = float('inf')

if not odd and not even: res = 0
if odd: res = min(res, sum(odd)+sum(even)-odd[-1])
if even: res = min(res, sum(odd)+sum(even)-even[-1])

print(res)