n = int(input())
a = list(map(int,input().split()))
even, odd = [],[]
for s in a:
    if s%2==0:
        even.append(s)
    else:
        odd.append(s)
even.sort()
odd.sort()
diff = len(even)-len(odd)
ans = 0
if diff>1:
    print(sum(even[-diff+1:]))
elif diff<-1:
    print(sum(odd[diff+1:]))
else:
    print(0)