n = int(input())
array = list(map(int, input().split()))
odds = 0
evens = 0


def check(number):
    if number % 2 == 0:
        return True


for x in array:
    if check(x):
        evens += 1
    else:
        odds += 1

if odds == evens:
    print(0)
elif (odds - 1) == evens:
    print(0)
elif odds == (evens - 1):
    print(0)
else:
    if odds > evens:
        a = sorted(array)
        sums = 0
        for i in range(1, n + 1):
            if i % 2 != 0:
                if not check(a[i-1]):
                    sums += a[i-1]
            # else:
            #     sums += a[i-1]
        print(sum(array) - sums)
    else:
        sums = 0
        a = sorted(array)
        for i in range(1, n + 1):
            if i % 2 != 0:
                if check(a[i-1]):
                    sums += a[i-1]
            # else:
            #     sums += a[i-1]
        print(sum(array) - sums)
