n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)

odd,even=[],[]
for num in a:
    if num%2==1:
        odd.append(num)
    else:
        even.append(num)

tmp = min(len(odd),len(even))
result = sum(a)-sum(odd[:tmp])-sum(even[:tmp])
if len(odd)!=len(even):
    result -= (odd[tmp] if len(odd)>len(even) else even[tmp])
print(result)