def solve(values):
    odd = sorted(value for value in values if value % 2 == 1)
    even = sorted(value for value in values if value % 2 == 0)
    if abs(len(odd) - len(even)) <= 1:
        return 0

    if len(even) > len(odd):
        return sum(even[:len(even) - len(odd) - 1])
    return sum(odd[:len(odd) - len(even) - 1])


def main() -> None:
    n = int(input())
    values = list(map(int, input().split()))
    print(solve(values))


if __name__ == '__main__':
    main()
