n = int(input())
numl = list(map(int,input().split()))
numl.sort()

even, odd = [],[]
for i in numl:
    if i%2==0:
        even.append(i)
    else:
        odd.append(i)
le=len(even)
lo = len(odd)
if abs(le-lo) <2:
    print(0)
elif le>lo:
    print(sum(even[:le-lo-1]))
else:
    print(sum(odd[:lo-le-1]))