n = int(input())

array = list()
Sum = 0
odd = list()
even = list()
array = [int(x) for x in input().split(" ")]
for number in array:
    Sum += number
    if number % 2:
        odd.append(number)
    else:
        even.append(number)

odd.sort(reverse=True)
even.sort(reverse=True)

k = min(len(odd), len(even))
Sum -= (sum(odd[:k]) + sum(even[:k]))
if len(odd) > k:
    Sum -= odd[k]
if len(even) > k:
    Sum -= even[k]

print(Sum)
