n=int(input())
s=list(map(int,input().split()))
ss=sorted(s)
oddcnt,evencnt=[],[]
for i in range(n):
    if(ss[i]%2):
        oddcnt.append(ss[i])
    else:
        evencnt.append(ss[i])
sum=0
ol,el=len(oddcnt),len(evencnt)
if(ol>=el):
    for i in range(ol-el-1):
        sum+=oddcnt[i]
    print(sum)
else:
    for i in range(el-ol-1):
        sum+=evencnt[i]
    print(sum)