Number of integer-order triplets $(i,j,k)$ where $1 \le i \le k \le j \le N$ I have a copy of Data Structures & Problem Solving using Java, 2nd edition by Weiss. There is a theorem in the text book with a proof that I just don't understand.

Theorem
Number of integer-order triplets $(i,j,k)$ where $1 \le i \le k \le j \le N$ is
  $\dfrac{N(N+1)(N+2)}{6}$.
Proof
Place the following $N+2$ balls in a box: N balls numbered from $1$ to
  $N$, one unnumbered red ball, and one unnumbered blue ball. Remove
  three balls from the box. If a red ball is drawn, number it as the
  lowest of the numbered balls drawn. If a blue ball is drawn, number it
  as the highest of the numbered balls drawn. Notice that if we draw
  both a red ball and a blue ball, then the effect is to have three
  balls identically numbered. Order the three balls. Each such order
  corresponds to a triplet solution to the equation in the theorem. The
  number of possible orders is the number of distinct ways to draw three
  balls without replacement from a collection of $N + 2$ balls.

I don't understand where the numbered extra balls come in and why we are adding them to the box before we draw out balls from the box in threes.
 A: The extra balls are to account for triplets with two or three identical elements. Without the extra balls you’d have $\binom{N}3$ sets of distinct integers in $\{1,\ldots,N\}$, each of which would gives you exactly one ordered triple $\langle i,j,k\rangle$ with $i<j<k$. 
Now add the red ball. It’s a kind of joker: when you draw it along with two of the numbered balls, you give the red ball the same number as the lower of the numbers on the other two balls. Suppose that you draw the red ball and balls number $j$ and $k$, where $j<k$; this represents the triple $\langle j,j,k\rangle$. You can still draw three numbered balls, so you can still draw all of the triples $\langle i,j,k\rangle$ with $i<j<k$, but you can also draw the triples of the form $\langle i,j,k\rangle$ with $i=j<k$. There are now $\binom{N+1}3$ sets of three balls that you can draw, so there are $\binom{N+1}3$ triples $\langle i,j,k\rangle$ such that $i\le j<k$.
Finally, add the blue ball. It’s another joker, but instead of assuming the value of the lowest-numbered ball drawn, it assumes the value of the highest-numbered ball drawn. Without the red ball this would give you draws corresponding to triples $\langle i,j,k\rangle$ with $i<j\le k$. However, you can also draw triples consisting of the red ball, the blue ball, and one numbered ball, say number $j$. The red ball is interpreted as a copy of the lowest-numbered ball drawn; the only numbered ball drawn is the $j$-ball, so the red ball is interpreted as a second $j$-ball. Similarly, the blue ball is interpreted as a copy of the highest-numbered ball drawn, so it’s a third $j$-ball. Thus, the draw corresponds to the triple $\langle j,j,j\rangle$.
Thus, with the red and blue balls both available, each set of $3$ balls can be uniquely interpreted as a triple $\langle i,j,k\rangle$ with $i\le j\le k$; the red balls give us the cases in which $i=j$, and the blue balls the cases in which $j=k$. Since there are altogether $N+2$ balls in the box, there are $$\binom{N+2}3=\frac{N(N+1)(N+3)}6$$ possible sets of $3$ balls that can be drawn, and therefore the same number of ordered triples $\langle i,j,k\rangle$ such that $1\le i\le j\le k\le N$.
