# -*- coding: utf-8 -*-
"""
Created on Sun Mar  3 23:50:56 2019

@author: loyuli
"""
n = int(input())
s = list(map(int, input().split()))
odd = []
even = []
for i in s:
    if i % 2 == 0:
        even.append(i)
    else:
        odd.append(i)
odd.sort()
even.sort()
if abs(len(odd) - len(even)) <= 1:
    print(0)
else:
    m = min(len(odd), len(even))
    if len(odd) > len(even):
        print(sum(odd[:-m-1]))
    else:
        print(sum(even[:-m-1]))