n = int(input())
numbers = list(map(int, input().split()))

odd = []
even = []
for i in numbers:
    if i % 2 == 0:
        even.append(i)
    else:
        odd.append(i)
odd.sort(reverse=True)
even.sort(reverse=True)

if len(odd) == len(even):
    print(0)
    exit()
if len(odd) < len(even):
    res = sum(numbers) - sum(odd) - sum(even[:len(odd) + 1])
if len(odd) > len(even):
    res = sum(numbers) - sum(even) - sum(odd[:len(even) + 1])
print(res)