def calc(a, b):
    return sum(a) + sum(b[-(len(a) + 1):])


_ = int(input())
numbers = list(map(int, input().split()))

odds = sorted(x for x in numbers if x % 2 == 1)
evens = sorted(x for x in numbers if x % 2 != 1)

deleted = calc(odds, evens) if len(odds) < len(evens) else calc(evens, odds)
print(sum(numbers) - deleted)
