

def minimizeUndeletedSum(array):
    even = sorted([i for i in array if i % 2 == 0])
    odd = sorted([i for i in array if i % 2 == 1])

    even_l = len(even)
    odd_l = len(odd)

    if abs(even_l - odd_l) <= 1:
        return 0

    if even_l > odd_l:
        return sum(even[:odd_l - 1])

    return sum(odd[:even_l - 1])


if __name__ == "__main__":
    n = int(raw_input())
    a = map(int, raw_input().split())
    print(minimizeUndeletedSum(a))
