n = int(input())
a = list(map(int, input().split()))
even = []
odd = []
for i in range(n):
    if a[i] % 2 == 0:
        even.append(a[i])
    else:
        odd.append(a[i])

even.sort()
even = even[::-1]
odd.sort()
odd = odd[::-1]
if abs(len(odd) - len(even)) <= 1:
    print(0)
else:
    o = len(odd)
    e = len(even)
    if o > e:
        print(sum(odd[e+1:]))
    else:
        print(sum(even[o+1:]))
