n = input()
a = map(int, raw_input().strip().split())

odd = []
even = []

for num in a:
    if num & 1: odd.append(num)
    else: even.append(num)

diff = abs(len(odd) - len(even))

if diff < 2:
    print 0
    exit()

diff -= 1
if len(odd) > len(even):
    odd.sort()
    ans = 0
    for i in xrange(diff): ans += odd[i]
    print ans
else:
    even.sort()
    ans = 0
    for i in xrange(diff): ans += even[i]
    print ans