Although there are 14 teams in the lottery and 14 Ping-Pong balls, that match is just a coincidence. The number of Ping-Pong balls was chosen because there are exactly 1,001 ways that four numbers can be drawn from a set of 14. Each of those combinations is assigned to a team. The Minnesota Timberwolves, who had the worst record this season and have a 25 percent chance of getting the top pick, receive the first 250 combinations: 1, 2, 3, 4; 1, 2, 3, 5; 1, 2, 3, 6 — all the way to 1, 7, 12, 14. The Knicks, the next-worst team, get the next 199 combinations, and so on down to the Oklahoma City Thunder, who have only five combinations and an 0.5 percent chance at the top pick.

The 1,001st and final combination — 11, 12, 13, 14 — is unassigned; if it is drawn, the balls will be put back and drawn again. As in most lotteries, the order in which the balls are drawn does not matter — 1, 3, 9, 12 is considered the same as 3, 12, 9, 1.

Officials will hastily consult a chart and announce to the select few in the room which team has won the top pick. Then the balls will be returned to the hopper, and the second pick will be drawn, by the same process, and then the third. If a team is repeated, that draw will be disregarded and redone until a new team comes up.

Once the top three picks are determined, the lottery will be over. Slots 4 through 14 will be assigned based solely on record. As a result, the Timberwolves, even if they are not pulled in the three draws, will get no worse than the fourth pick.

For Knicks fans, the math looks like this: They have a 19.9 percent chance to have one of their combinations pulled for the top pick, an 18.8 percent chance for pick No. 2, and a 17.1 percent chance for pick No. 3 — in total, a 55.8 percent chance at a top-three pick.

If their combinations are not drawn, they will slip to No. 4 (31.9 percent) or No. 5 (12.3 percent), but no lower.

The lottery will be videotaped and will be posted on the N.B.A.’s website, but only after the televised ceremony is over.