n = int(input())
arr = list(map(int,input().split()))
odds, evens = [], []
for i in range(n):
    if arr[i]%2==0: evens.append( arr[i] )
    else: odds.append( arr[i] )
evens.sort()
odds.sort()
even = len(evens) > len(odds) 
while True:
    if even:
        if len(evens) > 0: evens.pop()
        else: break
        even = not even
    else:
        if len(odds) > 0: odds.pop()
        else: break
        even = not even
print( sum(evens)+sum(odds) )