n = int(input())
a = list(map(int,input().split()))
odd = []
even = []
for i in a:
    if i&1:
        odd.append(i)
    else:
        even.append(i)
odd.sort()
even.sort()
odd_count = len(odd)
even_count = len(even)
min_count = min(odd_count, even_count)
if abs(odd_count - even_count) <= 1:
    res = 0
else:
    res = sum(even[:-(min_count+1)]) if odd_count <= even_count else sum(odd[:-(min_count+1)])
print(res)