n = int(input())
x = list(map(int, input().split()))
odd_cnt, even_cnt = 0, 0
odd, even = [], []
for i in range(n):
    if x[i] % 2 == 0:
        even_cnt += 1
        even.append(x[i])
    else:
        odd_cnt += 1
        odd.append(x[i])
even.sort()
odd.sort()
if abs(odd_cnt - even_cnt) > 1:
    if even_cnt > odd_cnt:
        print(sum(even[:even_cnt - odd_cnt - 1]))
    else:
        print(sum(odd[:odd_cnt - even_cnt - 1]))
else:
    print(0)
