n=int(input())
arr=[int(x) for x in input().split()]
e=[]
o=[]
for i in range(len(arr)):
    if arr[i] % 2:
        e.append(arr[i])
    else:
        o.append(arr[i])

m=0
if len(e)>len(o):
    e.sort()
    for i in range(len(e)-len(o)-1):
        m+=e[i]
else:
    o.sort()
    for i in range(len(o)-len(e)-1):
        m+=o[i]
print(m)