n = int(raw_input())
array = sorted(map(int, raw_input().split()))

odd = []
even = []

for i in xrange(n):
    if array[i] % 2 == 0:
        even.append(array[i])
    else:
        odd.append(array[i])

odds = len(odd)
evens = len(even)

if abs(odds - evens) <= 1:
    print '0'
elif odds > evens:
    print sum(odd[:odds - evens - 1])
else:
    print sum(even[:evens - odds - 1])