chet=[]
nochet=[]
n=int(input())
a=[int(x) for x in input().strip().split()]
for i in a:
    if i%2==0:
        chet.append(i)
    else:
        nochet.append(i)
chet.sort()
nochet.sort()
summ=0
ma=max(len(chet),len(nochet))
for i in range(ma):
    if len(chet)-i>len(nochet)+1:
        summ+=chet[i]
    elif len(nochet)-i>len(chet)+1:
        summ+=nochet[i]
print(summ)
