n=int(input())
a=list(map(int,input().split()))
o=[a[i] for i in range(n) if a[i]%2 ==1]
e=[a[i] for i in range(n) if a[i]%2 ==0]
o.sort()
e.sort()
if len(o)==len(e):
    print(0)
elif abs(len(o)-len(e))==1:
    print(0)
elif len(o)>len(e):
    print(sum(o[:len(o)-len(e)-1]))
elif len(e)>len(o):
    print(sum(e[:len(e)-len(o)-1]))