n = int(input())
nums = [int(x) for x in input().split(' ')]
nums.sort()
evens = []
odds = []

for i in nums:
  temp = str(i)
  if int(temp[-1])%2 == 0:
    evens.append(i)
  else:
    odds.append(i)

# print(evens)
# print(odds)
evensLen = len(evens)
oddsLen = len(odds)
resp = 0
if evensLen != oddsLen:
  if evensLen > oddsLen:
    for i in range(evensLen - oddsLen - 1):
      resp += int(evens[i])
  else:
    for i in range(oddsLen - evensLen - 1):
      resp += int(odds[i])


print(resp)
