input()
X = list(map(int, input().split()))
Odd, Even = [], []
for i in X:
    if i % 2 == 0:
        Even.append(i)
    else:
        Odd.append(i)
if abs(len(Odd) - len(Even)) in [0, 1]:
    print(0)
    exit()
Odd, Even = sorted(Odd), sorted(Even)
if len(Odd) > len(Even):
    print(sum(Odd[:len(Odd) - len(Even) - 1]))
    exit()
print(sum(Even[:len(Even) - len(Odd) - 1]))
