n = int(input())
a = [int(s) for s in input().split()]
even = []
odd = []
a.sort()
for i in a:
    if i % 2 == 0:
        even.append(i)
    else:
        odd.append(i)
ev = len(even)
od = len(odd)
if abs(ev-od) <= 1:
    print(0)
elif ev > od:
    print(sum(even[:ev-od-1]))
elif od > ev:
    print(sum(odd[:od-ev-1]))