num = int(input())

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

odds = [i for i in arr if i % 2 != 0]

evens = [i for i in arr if i % 2 == 0]

if abs(len(odds)-len(evens)) < 2:
    print(0)
else:
    if len(odds) > len(evens):
        i = len(odds) - len(evens)-1
        odds.sort()
        ans = sum(odds[:i])
    else:
        i = -len(odds) + len(evens)-1
        evens.sort()
        ans = sum(evens[:i])
    print(ans)
