n = int(input())
a = list(map(int, input().split()))
evens = []
odds = []
for i in a:
    if i % 2 == 0:
        evens.append(i)
    else:
        odds.append(i)
evens.sort()
odds.sort()
le = len(evens)
lo = len(odds)
non_del = max(0, abs(le - lo) - 1)
if le > lo:
    print(sum(evens[:non_del]))
else:
    print(sum(odds[:non_del]))