n = int(input())
array = list(map(int, input().split(' ')))
evens = []
odds = []
for i in array:
    if (i % 2 == 0):
        evens.append(i)
    else:
        odds.append(i)
evens.sort(reverse = False)
odds.sort(reverse = False)
if abs(len(evens) - len(odds)) <= 1:
    print(0)
    exit(0)
firstsum = 0
if len(evens) > len(odds):
    difflen = len(evens) - len(odds)
    print(sum(evens[:difflen - 1]))
else:
    difflen = len(odds) - len(evens)
    print(sum(odds[:difflen - 1]))