import sys
input = sys.stdin.readline
n = int(input())
arr = list(map(int, input().split()))
odd = sorted([i for i in arr if i % 2 == 1])
even = sorted([i for i in arr if i % 2 == 0])
for i in range(min(len(odd), len(even))):
    odd.pop()
    even.pop()
if len(odd) >= 1:
    odd.pop()
elif len(even) >= 1:
    even.pop()
print(sum(odd) + sum(even))
