1. Concise Abridged Statement  
––––––––––––––––––––––––  
You have N players and you must schedule a sequence of chess games so that:  
- In the first game any two players meet.  
- In each subsequent game, one of the players is the winner of the previous game.  
- No game is drawn.  
You are given an array a[1..N], where a[i] is the total number of games player i must play. Construct any valid sequence of games (winner, loser) that uses exactly ∑a[i]/2 games and in which each player i appears exactly a[i] times (either as winner or loser).

2. Detailed Editorial  
––––––––––––––––  
Let G = (∑a[i]) / 2 be the total number of games; it is guaranteed that ∑a[i] is even and that a solution exists.

Key idea: we maintain a “current champion” who must appear in every match (except the first game where we pick any champion). We will build the match list one by one, always honoring the rule that the previous winner (the champion) plays next.

Greedy strategy:  
1. Sort players in descending order of remaining games. Call the sorted degrees b[0] ≥ b[1] ≥ … ≥ b[N–1] and let id[0..N–1] be their original indices. The champion will always sit at index p=0 in this sorted list.  
2. We iterate G times to schedule each game. At each step:  
   - If b[0] > 1, let the champion win. We record a partial match (champion, placeholder) and decrement b[0] by 1. We will assign the actual opponent later.  
   - If b[0] == 1, then if the champion plays and wins, he would have zero games left but we still need to hand off the champion token to someone who has remaining games. So instead we force the champion to lose to the next-strongest player (index 1). We record (index 1 beats index 0), decrement b[1] and b[0], and advance p++ so the new champion is at the old index 1.  
3. After this first pass, every game where the champion won has recorded only the winner and a “–1” placeholder for the loser. We now walk through those games in order and assign real opponents greedily from the pool of players with undepleted degrees (we keep a pointer q that skips over any b[q]==0). Each time we assign an opponent to a “champion-win” match, we decrement that opponent’s remaining games.  
4. Finally we output the G matches in the order we created them, translating the 0-based sorted indices back to the original player labels.

Why it works:  
- At each step, the champion (who must play) has at least one remaining game, so we never “get stuck.”  
- For b[0]>1 we let the champion win, preserving him as champion and consuming one of his matches.  
- When exactly one match remains for champion, we force him to lose to hand off the champion token to someone else who still needs matches.  
- Every match consumes exactly two game‐slots, and by the end all b[*] are zero.

Time complexity: sorting O(N log N) plus O(G + N), comfortably within limits since G ≤ 10 000.

3. Provided C++ Code with Line-by-Line Comments  
––––––––––––––––––––––––––––––––––––––  
```cpp
#include <bits/stdc++.h>
using namespace std;

// Overload << and >> for convenience with pairs and vectors
template<typename T1, typename T2>
ostream& operator<<(ostream& out, const pair<T1, T2>& x) {
    return out << x.first << ' ' << x.second;
}
template<typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& x) {
    return in >> x.first >> x.second;
}
template<typename T>
istream& operator>>(istream& in, vector<T>& a) {
    for (auto& x : a) in >> x;
    return in;
}
template<typename T>
ostream& operator<<(ostream& out, const vector<T>& a) {
    for (auto& x : a) out << x << ' ';
    return out;
}

int n;
vector<int> a;  // original degrees

void read() {
    cin >> n;
    a.resize(n);
    cin >> a;
}

void solve() {
    // Total games = sum(a[i]) / 2
    int total = accumulate(a.begin(), a.end(), 0);
    assert(total % 2 == 0);
    int G = total / 2;

    // Build a permutation of players sorted by descending degree
    vector<int> perm(n);
    iota(perm.begin(), perm.end(), 0);
    sort(perm.begin(), perm.end(), [&](int i, int j){
        return a[i] > a[j];
    });
    // Copy and sort the degrees b[]
    vector<int> b(n);
    for (int i = 0; i < n; i++) b[i] = a[perm[i]];
    
    // We'll collect matches as pairs (winner_index, loser_index)
    // loser_index == -1 means “to be assigned later”
    vector<pair<int,int>> matches;
    matches.reserve(G);

    int p = 0;  // p is the current champion in b[]

    // Phase 1: decide winner side of each game
    for (int i = 0; i < G; i++) {
        if (b[p] > 1) {
            // Champion wins → we can postpone picking his opponent
            matches.emplace_back(p, -1);
            b[p]--;
        } else {
            // Champion has exactly one game left:
            // force him to lose to b[p+1]
            matches.emplace_back(p+1, p);
            b[p]--;      // uses up champion’s last game
            b[p+1]--;    // uses up opponent’s game
            p++;         // new champion is at old index p+1
        }
    }

    // Phase 2: assign actual opponents for matches with loser = -1
    int q = 0;  // pointer to find any player with b[q] > 0
    for (auto& mv : matches) {
        if (mv.second != -1) continue;  // already assigned
        // skip players with no games left
        while (b[q] == 0) q++;
        mv.second = q;
        b[q]--; 
    }

    // Output result: translate back from sorted indices to original labels (+1)
    cout << G << "\n";
    for (auto& mv : matches) {
        int w = perm[mv.first] + 1;
        int l = perm[mv.second] + 1;
        cout << w << " " << l << "\n";
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    read();
    solve();
    return 0;
}
```

4. Python Solution with Detailed Comments  
––––––––––––––––––––––––––––––––––––  
```python
import sys

def main():
    data = sys.stdin.read().split()
    n = int(data[0])
    a = list(map(int, data[1:]))

    total = sum(a)
    assert total % 2 == 0
    G = total // 2

    # Create sorted order of players by descending games
    perm = list(range(n))
    perm.sort(key=lambda i: -a[i])

    # b[i] = remaining games of the player at sorted position i
    b = [a[i] for i in perm]

    matches = []  # will store tuples (winner_idx, loser_idx or -1)
    p = 0         # current champion pointer

    # Phase 1: decide winners & placeholders
    for _ in range(G):
        if b[p] > 1:
            # champion wins, postpone picking loser
            matches.append([p, -1])
            b[p] -= 1
        else:
            # champion must lose to pass on the token
            matches.append([p+1, p])
            b[p]   -= 1
            b[p+1] -= 1
            p += 1  # new champion

    # Phase 2: fill in the losers for placeholder matches
    q = 0
    for mv in matches:
        if mv[1] != -1:
            continue
        # find next player with leftover games
        while b[q] == 0:
            q += 1
        mv[1] = q
        b[q] -= 1

    # Print results, translating back to 1-based original indices
    out = [str(G)]
    for w, l in matches:
        # perm[w] is the original index, add 1 for 1-based
        out.append(f"{perm[w]+1} {perm[l]+1}")
    print("\n".join(out))

if __name__ == "__main__":
    main()
```

5. Compressed Editorial  
––––––––––––––––  
Sort players by remaining matches descending. Always keep the “current champion” at the front.  
- While champion has >1 games, let him win and record (champion, –1).  
- When he has exactly one left, force him to lose to the next player, decrement both, and advance the champion pointer.  
After scheduling all games, fill each “–1” loser slot by greedily picking any player who still needs matches. This produces a valid chain of G=∑a[i]/2 games in which each player appears exactly a[i] times.