num = int(input())
num_list = list(map(int, input().split()))

odd = []
even = []
for i in num_list:
      if i % 2 == 1:
            even.append(i)
      else:
            odd.append(i)
odd.sort(reverse=False)
even.sort(reverse=False)

num_diff = len(odd) - len(even)
# print(odd)
# print(even)
if abs(num_diff) <= 1:
      print(0)
elif num_diff > 1:
      print(sum(odd[:abs(num_diff)-1]))
else:
      print(sum(even[:abs(num_diff)-1]))

