def parDel(arr):
    eA = []
    oA = []
    e = 0
    o = 0
    
    for i in arr:
        if i % 2 == 0:
            eA.append(i)
            e += 1
        else:
            oA.append(i)
            o += 1
    
    eA.sort()
    oA.sort()
    
    if e - o > 1:
        ans = sum(eA[:(e-o-1)])
    elif o - e > 1:
        ans = sum(oA[:(o-e-1)])
    else:
        return 0
    
    return ans
    
    
n = int(input())

arr = list(map(int, input().split()))

print(parDel(arr))