n = int(input())
ar = list(map(int, input().split()))

odd = [ x for x in ar if(x&1) ]
even = [ x for x in ar if(x&1==0) ]

odd.sort(reverse = True)
even.sort(reverse = True)

if(len(odd) > len(even)):
    print(sum(odd[len(even)+1:]))
else:
    print(sum(even[len(odd)+1:]))