
n=int(input('')) 

#n,k=map(int, input().split())
a=list(map(int, input().split()))
e=[]
o=[]
s=0
for i in range(len(a)):
  if a[i]%2==0:
    e.append(a[i])
  else:
    o.append(a[i])  
e.sort()
o.sort()
if len(e)==len(o):
  print('0')
elif len(e)==len(o)+1 or len(o)==len(e)+1:
  print('0')
else:
  if len(o)<len(e):
    for i in range(len(e)-len(o)-1):
      s=s+e[i]
  else:
    for i in range(len(o)-len(e)-1):
      s=s+o[i]
  print(s)    



 