n = int(input())
s = map(int, input().split())
even = list()
odd = list()
for it in s:
    if it%2 == 0: even.append(it)
    else: odd.append(it)
if abs(len(even) - len(odd)) <= 1:
    print(0)
else:
    even = sorted(even)
    odd = sorted(odd)
    if len(even) > len(odd):
        print(sum(even[:-len(odd)-1]))
    else:
        print(sum(odd[:-len(even)-1]))
