n = int(input())
arr = list(map(int, input().split()))
even = []
odd = []
for i in range(len(arr)):
  if arr[i] % 2 == 0:
    even.append(arr[i])
  else:
    odd.append(arr[i])
even.sort(reverse = True)
odd.sort(reverse = True)
sc = sum(even) + sum(odd)
s = 0
if len(even) < len(odd):
  s += sum(even) + sum(odd[:(len(even) + 1)])
else:
  s += sum(odd) + sum(even[:(len(odd) + 1)])
print(sc - s)