This page is still under construction.

Parts of this page are still being built. What you see may change.

Coin Stacks

Interview

Time limit1sMemory limit1024 MB

Summary
Given n coin stacks, repeatedly remove one coin from two different nonempty stacks; decide if all coins can be removed and print a valid sequence of moves.
Level

Medium5 of 10

Topics
Greedy, Implementation, Simulation, Math
Solved
No attempts yet

Problem

A and B are playing a collaborative game that involves nn stacks of coins, numbered from 11 to nn. Every round of the game, they select a nonempty stack each, but they are not allowed to choose the same stack. They then remove a coin from both the two selected stacks and then the next round begins.

The players win the game if they manage to remove all the coins. Is it possible for them to win the game, and if it is, how should they play?

Input

The first line of input contains an integer nn (2≤n≤502 \le n \le 50), the number of coin stacks. Then follows a line containing nn nonnegative integers a1,a2,…,ana_1, a_2, \ldots, a_n, where aia_i is the number of coins in the ii'th stack. The total number of coins is at most 1 0001\,000.

Output

If the players can win the game, output a line containing "yes", followed by a description of the moves. Otherwise output a line containing "no". When describing the moves, output one move per line, each move being described by two distinct integers aa and bb (between 11 and nn) indicating that the players remove a coin from stacks aa and bb. If there are several possible solutions, output any one of them.

Examples2

  1. Example 1

    Input
    3
    1 4 3
    
    Expected output
    yes
    1 2
    2 3
    2 3
    2 3
    
  2. Example 2

    Input
    3
    1 1 1
    
    Expected output
    no