n = input()
l = list(map(int, input().split()))
odd = list()
even = list()

for i in l:
  if i % 2 == 0:
    even.append(i)
  else:
    odd.append(i)

odd.sort()
even.sort()

r = 0 
q = len(odd) - len(even)
w = len(even) - len(odd)

if q > 1:
  for i in range (q - 1):
      r = r + odd[i]
elif w > 1:
  for i in range (w - 1):
    r = r + even[i]

print(r)