length = int(raw_input())
numList = list1 = list(map(int, raw_input().split(' ')))
numOdd = 0
numEven = 0
for n in numList:
    if n % 2:
        numOdd += 1
    else:
        numEven += 1
if abs(numOdd - numEven) <= 1:
    print 0
else:
    margin = abs(numEven - numOdd) - 1
    ansList = []
    if numOdd > numEven:
        for n in numList:
            if n % 2:
                if len(ansList) < margin:
                    ansList.append(n)
                    ansList.sort()
                elif n < ansList[-1]:
                    ansList.pop()
                    ansList.append(n)
                    ansList.sort()
    else:
        for n in numList:
            if n % 2 == 0:
                if len(ansList) < margin:
                    ansList.append(n)
                    ansList.sort()
                elif n < ansList[-1]:
                    ansList.pop()
                    ansList.append(n)
                    ansList.sort()
    print sum(ansList)
