def minisum(arr):
    evens = list(filter(lambda a: a%2==0, arr))
    odds = list(filter(lambda a: a%2!= 0, arr))
    if abs(len(evens)-len(odds)) <= 1:
    
        return 0
    if len(evens) > len(odds):
        diff = (len(evens)-1) - len(odds)
        return sum(evens[0:diff])
    else:
        diff = (len(odds)-1) - len(evens)
        return sum(odds[0:diff])


n = int(input())
arr = list(map(int, input().split()))
print(minisum(arr))
