n = int(input())
a = list(map(int,input().split()))

y = list(filter(lambda x: x % 2 == 0, a))
n = list(filter(lambda x: x % 2 != 0,a))
y.sort()
y.reverse()
n.sort()
n.reverse()
if len(y) > len(n):
    a = y
    b = n
else:
    a = n
    b = y
if (y == n) or (len(y)+1 == len(n)) or (len(n)+1 == len(y)):
    print(0)
    quit()

ans = 0
for i in range(len(b)+1,len(a)):
    ans += a[i]

print(ans)