n = int(input().strip())

even, odd = [], []
for num in input().strip().split():
    num = int(num)
    if num % 2:
        odd.append(num)
    else:
        even.append(num)

len_diff = len(even) - len(odd)

if abs(len_diff) <= 1:
    print(0)
else:
    if len_diff < 0:
        target_nums = odd
    else:
        target_nums = even
    print(sum(sorted(target_nums)[:abs(len_diff) - 1]))