n = int(input())
a = sorted(map(int, input().split()))
even = [i for i in a if i%2 == 0]
odd = [i for i in a if i%2 != 0]
result = 0
if len(even) > len(odd):
    for i in range(abs(len(even)-len(odd))-1):
        result += even[i]
    print(result)
elif len(even) < len(odd):
    for i in range(abs(len(even)-len(odd))-1):
        result += odd[i]
    print(result)
else:
    print(0)
