input()
a = [[], []]
for x in map(int, raw_input().split()) :
    a[x&1].append(x)
a = map(sorted, a)
if len(a[0]) < len(a[1]) :
    a[0], a[1] = a[1], a[0]
if len(a[0]) == len(a[1]) :
    print 0
else :
    print sum(a[0][len(a[1])+1:])