'''
      Author : sea_26
      
'''


n = int(input())

a = list(map(int, input().split()))

a.sort()
a.reverse()
even = [x for x in a if x % 2 == 0]
odd = [x for x in a if x % 2 == 1]

x = min(len(odd), len(even)) + 1
print(sum(odd[x:]) + sum(even[x:]))
