if __name__ == '__main__':
    n = int(input())
    a = [int(x) for x in input().split()]
    odd = []
    even = []

    for i in a:
        if i % 2:
            odd.append(i)
        else:
            even.append(i)

    odd.sort(reverse=True)
    even.sort(reverse=True)

    t = sum(odd) + sum(even)
    k = min(len(odd), len(even))

    t -= sum(odd[:k])
    t -= sum(even[:k])

    if len(odd) > k:
        t -= odd[k]
    elif len(even) > k:
        t -= even[k]

    print(t)

