def minim_cf():
    n = int(input())
    m = list(map(int, input().split()))
    os = []
    es = []
    for i in range(len(m)):
        if m[i] % 2 == 0: es.append(m[i])
        else: os.append(m[i])
    os.sort()
    es.sort()
    oe = len(os)-len(es)
    eo = len(es)-len(os)
    if oe > 1:
        d = oe - 1
        return sum(os[:d])

    elif eo > 1:
        d = eo - 1
        return sum(es[:d])

    else: return 0

print(minim_cf())