n = int(input())
l=[int(x) for x in input().split()]
l.sort()
even,odd=[],[]
for i in l:
    if i%2==0:
        even.append(i)
    else:
        odd.append(i)
summ=0
#print(odd,even)

l1=int(len(odd))
l2=int(len(even))

#print(l1,l2)
if (l1==0)|(l2==0):
    summ=min(l)
    #print("sdakh")
elif l2>l1+1:
    ind = 0
    #print("sdakh1")
    while 1:
        summ += even[ind]
        ind += 1
        if ind == abs(l1-l2):
            break
elif l1>l2+1:
    ind = 0
    #print("sdakh2")
    while 1:
        summ += odd[ind]
        ind += 1
        if ind == abs(l1-l2):
            break

else:
    #print("sdakh")
    summ=0

print(summ)


#for x in range(n):
 #   y=int(input())
  #  l.append(y)