With the Iowa caucuses and Tuesday's New Hampshire primary now wrapped up, the race to rack up delegates in the contest for the Democratic presidential nomination is on. After a strong showing in New Hampshire, former South Bend, Indiana, Mayor Pete Buttigieg has a slight lead in the delegate count over Sen. Bernie Sanders, I-Vt. Convention delegates are chosen based on voter preferences in the primaries and caucuses held in each state or U.S. territory. The process sounds fairly simple: Delegates are chosen by the voters, and the candidate with the most delegates wins. But this year's race is turning out to be anything but simple. Here's how the Democratic delegate selection process will work:

How many delegates does a candidate need to get the nomination?

That depends. If a candidate gets to July's Democratic National Convention in Milwaukee with a simple majority of the pledged delegates, or at least 1,990 of the total of 3,979, that candidate is the nominee. Game over. If not, the nomination is considered contested. This is when the superdelegates start to matter. Superdelegates are also known as automatic delegates, even though their support for a given candidate is far from automatic. This group of 771 delegates is made up of Democrats in Congress, state and local party officials, Democratic governors and other party leaders, such as former presidents and vice presidents. So if none of the candidates wins 1,990 delegates by July, the magic number to win becomes 2,376 — or just one vote more than half of all delegates, including the superdelegates. Then the delegates vote. The superdelegates are barred from the first vote. If that first vote doesn't produce a clear winner, the superdelegates are then allowed to vote, presumably to prevent a stalemate.

What happens if none of the candidates gets a majority after all the delegates vote?

If that happens, expect plenty of behind-the-scenes deal-making as support shifts among the delegates pledged to candidates that no longer seem viable. Or the convention could settle on a compromise candidate who didn't even come close on the first round. It's been decades since multiple rounds of voting produced marathon conventions, but it could easily happen this summer. In 1924, the voting went more than 100 rounds before the Democrats settled on John W. Davis to run against the Republican incumbent, Calvin Coolidge. We may know fairly soon, though, whether the party is headed for a splintered convention. This year, the primary schedule is more heavily front-loaded than in the past. Some two-thirds of the pledged delegates will be chosen by the end of March.

How are the delegates chosen?

The pledged delegates are chosen directly by voters or indirectly in primaries or caucuses, where the delegate count is based more loosely on voter preferences. Some states hold a state convention where the delegates are officially designated. The superdelegates are chosen based on their party affiliation; many of them hold an elected office.

How many delegates does each state get?

The Democrats have a formula for that. You start with a "base" of 3,200 delegates nationwide and then apportion those delegates to each state based on how many votes Democrats cast in the last three elections, plus another share based on how many electoral votes each state gets. Each state then gets "bonus" votes on top of that, based on things such as when they choose to schedule their caucus or primary. You get bonus points if you pick a date that other states have picked, for example.

So the candidate who gets the most votes in a statewide caucus or primary gets the most delegates, right?

Sort of. The bulk of the pledged delegates — not the superdelegates — are picked based on the vote totals in each congressional district or state legislative district. Another batch, called at-large delegates, are chosen based on the total statewide vote. A third group, about 15% of the total, are called pledged PLEO delegates, which stands for Party Leader and Elected Officials. They're usually picked like the at-large group, based on overall state totals.

Seriously?

But don't confuse the pledged PLEO delegates with those unpledged PLEO delegates, aka superdelegates, who don't vote unless there's a contest. The makeup of the superdelegate group can be hard to pin down. That's because the final list can change right up until they get to Milwaukee, as elected officials and party leaders come and go over the course of the campaign. That's for the states and Puerto Rico. There are also six delegates assigned to American Samoa, Guam, Northern Mariana Islands and the Virgin Islands. Democrats abroad get 12 at-large delegates and one superdelegate. And the exact headcounts get even trickier, because there's a lot of rounding going on in these calculations. You can't have a fractional delegate.

What if a delegate can't make it to the convention?

No problem. Each state picks alternate delegates who stand in for absent delegates. They're still pledged to the same candidate as the regular delegate. Unless they're superdelegates, of course, who don't vote unless the convention is contested.

What if the delegates who go to the national convention don't vote the way they're supposed to?