# -*- coding: utf-8 -*-
import sys
from fractions import gcd
from fractions import gcd
def fi():
    return int(sys.stdin.readline())

def fi2():
    return map(int, sys.stdin.readline().split())

def fi3():
    return sys.stdin.readline()

def fo(*args):
    for s in args:
        sys.stdout.write(str(s)+' ')
    sys.stdout.write('\n')
INF=10**9+7
sys.setrecursionlimit(INF)

#main
n=fi()
a=raw_input().split()
a=[int(i) for i in a]
a.sort()
co=0
ce=0
for i in a:
    if i%2==0:
        ce+=1
    else:
        co+=1

if abs(co-ce)<=1:
    fo(0)
elif co>ce:
    d=co-ce-1
    s=0
    count=0
    for i in a:
        if i%2==1:
            s+=i
            count+=1
        if count==d:
            break
    fo(s)

else:
    d=ce-co-1
    s=0
    count=0
    for i in a:
        if i%2==0:
            s+=i
            count+=1
        if count==d:
            break
    fo(s)
    
            
            
            

    


    
    
    
        
        
    
        

    
            
              
    
    
    
    
    
    
    
        
    
    
    


            
    
        
            
                
            
            
 
    


    

    
        
            
            
            
    
    
    
    
    
    


    


    
            
        
    
    
        
        
    
    
    
        
        
        

 




        
        
        
        

 



