n = int(input())
arr = [int(x) for x in input().split()]
arr.sort()
odd = []
even = []
for e in arr:
    if e % 2 == 1:
        odd.append(e)
    else:
        even.append(e)
answer = 0
if len(odd) > len(even):
    odd_num = len(odd) - len(even) - 1
    answer = sum(odd[:odd_num])
if len(even) > len(odd):
    even_num = len(even) - len(odd) - 1
    answer = sum(even[:even_num])
print(answer)
