n = int(input())
a = list(map(int, input().split()))
s1 = [sorted([q for q in a if q % 2 == 0]), sorted([q for q in a if q % 2 == 1])]
s2 = [s1[0][::], s1[1][::]]
start = 0
while len(s1[start]) > 0:
    s1[start].pop()
    start = 1-start
ans1 = sum(s1[0])+sum(s1[1])
start = 1
while len(s2[start]) > 0:
    s2[start].pop()
    start = 1-start
ans2 = sum(s2[0])+sum(s2[1])
print(min(ans1, ans2))
