N = int(input())
numbers = sorted([ int(x) for x in input().split(' ')], reverse=True)
odd = []
even = []
for x in numbers:
    if (x%2==0) :
        even.append(x)
    else:
        odd.append(x)

#print(even)
#print(odd)

if len(even) == len(odd)+1 or len(even)+1 == len(odd) or len(even) == len(odd) :
    print(0)
elif( len(even) > len(odd) ):
    print(sum(even[len(odd)+1:]))
else:
    print(sum(odd[len(even)+1:]))