#https://codeforces.com/contest/1144/problem/B

n=int(input())
l=list(map(int,raw_input().split()))
l.sort()
l=l[::-1]
odd,even=[],[]
for i in xrange(len(l)):
    if l[i]%2==0:
        even.append(l[i])
    else:
        odd.append(l[i])
#print even,odd
if len(odd)>len(even):
    u=len(even)
    even=even[u:]
    odd=odd[u+1:]
#    print even ,odd
else:
    u=len(odd)
    even=even[u+1:]
    odd=odd[u:]
#    print even ,odd
print sum(even)+sum(odd)