

n = int(input())
l = list(map(int,input().split()))
odd = []
even = []
l.sort()
for i in range(n):
    if(l[i] % 2 == 0):
        odd.append(l[i])
    else:
        even.append(l[i])

no = len(odd)
ne = len(even)
if(no == ne):
    print(0)
elif(no < ne):
    diff = ne - no
    #print(even[0:diff:1])
    print(sum(even[0:diff:1]) - max(even[0:diff:1]))
else:
    diff = no - ne
    #print(odd[0:diff:1])
    print(sum(odd[0:diff:1]) - max(odd[0:diff:1]))
