Ted finally finishes telling his kids the story of how he met their mother on the one-hour series finale of "How I Met Your Mother" on Monday, March 31 on CBS. Pictured:Jason Segel as Marshall, Josh Radnor as Ted, Alyson Hannigan as Lily, and Neil Patrick Harris as Barney.

Photo: Ron P. Jaffe, CBS

Ted finally finishes telling his kids the story of how he met their...

Nine years of laughter and occasional fits of exasperation come to an end Monday with the finale of "How I Met Your Mother," the mainstay of the formidable CBS Monday night sitcom lineup and one of the great ensemble shows of contemporary television.

On the surface, ensemble shows seem to make perfect sense: Create five or six characters (preferably single) who share space and oxygen, write some jokes for them to say, and if the audience doesn't like one character, chances are they'll like another.

Some stars inevitably shine brighter than others - Rachel Green in "Friends," Sam Malone in "Cheers," Sheldon Cooper in "Big Bang Theory"- but it's a matter of relative luminescence for the most part. It's called hedging your bets, as opposed to banking on one star to carry a show.

Beneath the surface, however, ensemble shows have their own particular challenge: Not only do you have to have the right chemistry between two leading actors, but among other ensemble members as well. If they work together well enough as a group, maybe viewers won't care that much about the weaker links.

Hollywood is littered with failed ensemble shows - "Don't Trust the B- in Apt. 23," "We Are Men," "Happy Endings," to name a few. "New Girl" didn't really start out as an ensemble show, but as a vehicle for Zooey Deschanel. It hit its stride only after it became the ensemble show it is today.

No doubt, TV show creators look to the immortals like "Friends," "Cheers" and "How I Met Your Mother" to decipher the secret to making them work.

"HIMYM" started out with a somewhat artificial framework to nudge us forward from week to week: "Kids," each episode would begin (voiceover by Bob Saget), as future Ted Mosby (Josh Radnor) supposedly told his kids how he met their mother years before.

Many teases

Over the show's nine-year run, creators Craig Thomas and Carter Bays occasionally renewed the extended tease, with Ted falling for one guest-starring actress or another.

For a while, Sarah Chalke seemed a sure thing, but, of course, wasn't. That's where the exasperation came in. The rest of the time, millions of us were perfectly happy with Ted's indefatigable romanticism, Robin's (Cobie Smulders) Canadian pride, Barney's (Neil Patrick Harris) "legen-dary" womanizing, and Marshall and Lily's (Jason Segal, Alyson Hannigan) attempts at grown-up marriage.

Finally rounding the clubhouse turn, the show introduced us to the girl with the umbrella, played by Cristin Milioti, a charming young actress who nonetheless may not seem right for the role of the mother to you.

That's probably because, over nine years, we've all come up with our ideal mate for Ted. During a visit to the "HIMYM" set on the Fox lot in January, Milioti was tellingly deferential to her cast-mates and showed her age when she revealed, "I watched all eight seasons in three months. I did binge on it, and it is amazing to have it, like, at the surface, because I cried hysterically, laughed. ....I hadn't seen it, which means nothing because I just saw 'Pretty Woman' over the weekend."

So what is the secret of "HIMYM's" success? An absolutely perfect cast, consistently smart direction by one of the best in the business, Pamela Fryman, and great writing - writing that not only managed to be funny more often than not, but which also respected the quirks and nuances of each character.

The catch phrases (mostly Barney's), the running jokes (Robin's early career as Canadian pop star Robin Sparkles), the central presence of the couch in the living room and that one red-leather booth at MacLaren's Pub they all share - made the show memorable, but also gave it grounding to strengthen the bond with viewers.

False temptation

Many show creators make the mistake of thinking that the secret to making an ensemble sitcom is following some kind of template about the characters: You have to have a randy one, a less intelligent or spacey one, a romantic, a cynic, etc. Think about some of the great ensemble shows of the past and it's probably easy to figure out why the One From Column A approach is so enticing.

But the truth is, you could assemble many of the elements that made "HIMYM" work for nine years and still come up with junk without the two most important ingredients: Excellent writing and a talented, appealing cast.

Bays and Thomas are now working on a new show, to be titled "How I Met Your Father." It will have no connection to "Mother," but using that title is dangerous: No matter how different the new show is, if it's called "How I Met Your Father," you can be sure viewers will make comparisons.

If it turns out to be an equally great show, no problem. But given how many bad ensemble shows get launched and how few are good enough to survive nine seasons at the top of their game, Bays and Thomas have their work cut out for them.

For now, though, let's figuratively crowd into that red booth one more time and raise a glass to a - wait for it - TV classic.