# # # coding=utf-8
# # # Author: lee215

get = lambda: int(raw_input().strip())
getl = lambda: raw_input().strip()
gets = lambda: map(int, raw_input().strip().split())
getss = lambda n: [gets() for _ in xrange(n)]


N = get()
A = gets()


odd = [a for a in A if a % 2]
even = [a for a in A if a % 2 == 0]

if abs(len(odd) - len(even)) <= 1:
    print 0
else:
    no = len(odd)
    ne = len(even)

    if no > ne:
        need = no - ne - 1
        print sum(sorted(odd)[:need])
    else:
        need = ne - no - 1
        print sum(sorted(even)[:need])
