n = int(input())
l = [int(x) for x in input().split()]
even = [x for x in l if x%2==0]
odd = [x for x in l if x%2==1]
even.sort(reverse=True)
odd.sort(reverse=True)
ol,el = len(odd),len(even)
if ol == el:
    print(0)
elif ol < el:
    even = even[ol+1: ]
    print(sum(even))
else:
    odd = odd[el+1:]
    print(sum(odd))