# import sys
# sys.stdin = open("in.txt", "r")
n = int(input())
x = [int(i) for i in input().split()]
odd = []
even = []
for i in x:
    if i%2:
        odd.append(i)
    else:
        even.append(i)
even.sort(reverse = True)
odd.sort(reverse = True)
# print(even)
# print(odd)
diff = len(even) - len(odd)
if diff <= 1 and diff >= -1:
    sum = 0
elif len(even) > len(odd):
    sum = sum(even[len(odd)+1:])
else:
    sum = sum(odd[len(even)+1:])
print(sum)