n = int(input())
ai = list(map(int,input().split()))
even = [i for i in ai if i%2 == 0]
odd = [i for i in ai if i%2 != 0]
even.sort()
odd.sort()

#print(even,odd)
if (len(odd) > len(even)):
    leftoverelements = len(odd) - len(even) - 1
    print(sum(odd[:leftoverelements]))


elif (len(even) > len(odd)):
    leftoverelements = len(even) - len(odd) - 1
    print(sum(even[:leftoverelements]))

else:
    print(0)