no_of_elements=int(input())
array=list(map(int,input().split()))

odd_array = sorted(list(filter(lambda x : x%2!=0 , array)),reverse = True)

even_array = sorted(list(filter(lambda x : x%2==0 , array)), reverse = True)

a=min(len(even_array),len(odd_array))
print(sum(odd_array[a+1:])+sum(even_array[a+1:]))


