import math
import re
import sys

def read(type = int):
  return type(raw_input())
  
def read_list(type = int, split = ' ', F = None):
  if F:
    return map(lambda x: F(type(x)), raw_input().split(split))
  return map(type, raw_input().split(split))

def read_list_of_list(N, type = int, split = ' ', F = None):
  return [read_list(type, F = F) for _ in xrange(N)]
  
  
  
n = read()
A = read_list()

o = sorted([a for a in A if a&1])
e = sorted([a for a in A if a&1==0])

X = [o, e]
i = 0
while X[i]:
  X[i] = X[i][1:]
  i = 1-i
  
s = sum(X[0])+sum(X[1])

o = sorted([a for a in A if a&1])
e = sorted([a for a in A if a&1==0])

X = [o, e]
i = 1
while X[i]:
  X[i] = X[i][1:]
  i = 1-i
  
s = min(s, sum(X[0])+sum(X[1]))
print s
