from sys import stdin, stdout
cin, cout = stdin.readline, stdout.write
size = int(cin())
array = map(int, cin().split())
odd, even = list(), list()
for i in array:
    if i%2: odd.append(i)
    else: even.append(i)
o, e = len(odd), len(even)
odd.sort();even.sort()
if o > e: ans = sum(odd[:o-e-1])
elif o < e: ans = sum(even[:e-o-1])
else: ans = 0
cout("%d\n"%ans)
