n = input()
a = input().split()
a = [int(i) for i in a]
a_odd = [i for i in a if i %2 == 1]
a_even = [i for i in a if i %2 == 0]
a_odd.sort()
a_even.sort()
if len(a_odd) > len(a_even) + 1:
    print(sum(a_odd[0:len(a_odd) - len(a_even) - 1]))
elif len(a_odd) + 1 < len(a_even):
    print(sum(a_even[0:len(a_even) - len(a_odd) - 1]))
else:
    print("0")