n = input()
a = map(int, raw_input().split())
a.sort()
odd = []
even = []
for x in a:
    if x % 2:
        odd.append(x)
    else:
        even.append(x)
lo = len(odd)
le = len(even)
if abs(le - lo) <= 1:
    print 0
else:
    if lo > le:
        print sum(odd[:abs(le - lo) - 1])
    else:
        print sum(even[:abs(le - lo) - 1])
