n = int(input())
l = [int(x) for x in input().split()]
l.sort()
l.reverse()
odd_list = list(filter(lambda x : x%2!=0,l))
even_list = list(filter(lambda x:x%2==0,l))
mini = min(len(odd_list),len(even_list))
print(sum(odd_list[mini+1:])+sum(even_list[mini+1:]))