# -*- coding: utf-8 -*-


if __name__ == "__main__":
    _ = int(input())
    array = list(map(int, input().split()))

    even = sorted([e for e in array if e % 2 == 0], reverse=True)
    odd = sorted([e for e in array if e % 2 == 1], reverse=True)

    deleted = min(len(even), len(odd)) + 1
    sum_rest = sum(even[deleted:]) + sum(odd[deleted:])
    print(sum_rest)
