This article has been updated.

The theory behind democracy — a good theory that I embrace — is that every vote counts. Every American goes to the polling place and casts a ballot, and then we add them up to see who has been chosen to serve in office. In reality, of course, there are scads of stumbling blocks — apathy, efforts to tamp down voting, etc. — that make this ideal come up short.

But one significant way in which it comes up short is that every vote often doesn’t count. When someone wins an election by a million votes, it’s hard to feel as though your particular vote made much of a difference.

Sometimes, though, it does. Sometimes, one vote is the difference between a candidate winning and a candidate losing. It’s rare, mind you, but not nonexistent.

Let’s come back to that. Let’s first assess what the results of elections look like nationally. To do so, we used data from the Associated Press’s voting results tabulations for all 50 states and the District of Columbia and determined how close the contests were on two metrics: margin of victory for the winner and the number of votes separating the first- and second-place candidates.

In total, the AP has data on 4,137 races, excluding those in which a candidate ran unopposed. (Those candidates had a remarkable track record of victory.) Here’s the distribution of margins of victory.

The median margin of victory was 22.1 points, meaning that half the races were closer and half were less close. On average, candidates (and issues) won by 25.7 points. Our congratulations to state Rep. Rod Scott, a Democrat, whose 98.8 percentage-point victory in Alabama’s 55th House District was the highest in the country.

The margins in terms of votes varied much more widely, given that the races ranged from statewide contests in Florida to each of New Hampshire’s 42,000 individual state legislative districts. The broadest vote margin came in the former state, with voters overwhelmingly approving Amendment 12, an anti-corruption measure.

All that’s fine. But what about the closest races? There were, by our count, 133 races of the 4,137 in which the margin was under 100 votes — 3.2 percent of all of the races. The AP data isn’t final, so those margins (and the ones below) might change.

The 40 closest races were all within 26 votes or less. That includes the race in Kentucky’s state House District 13, in which Jim Glenn (D) beat incumbent Rep. D.J. Johnson (R) by a 6,319-to-6,318 vote. That’s a one-vote margin. Every vote there counted. (There were two other one-vote margins, both in New Hampshire races in which multiple candidates won in each district.)

The closest race in which more than more than 50,000 votes were cast was in Illinois’s 21st state Senate district. Incumbent Republican Michael Connelly (R) led by 12 votes over Laura Ellman (D). In 2012 and 2014, he ran unopposed.

Update: That margin, though, has shifted as more votes have been counted. Ellman now leads Connelly. It’s a reminder both that close races often see shifts in the days after elections -- and, as the headline states, that every vote counts.

By percentage-point margin, the closest race is still one of those New Hampshire races; the Illinois race is in the top five. About 180 races were settled by one point or less, according to the AP’s data, more than 4 percent of the uncontested races.

Here we see two other interesting additions to the top 40: Florida’s U.S. Senate and agriculture commissioner races. These were two of the closest races in the country, and while the margins were 10,033 and 6,753 votes, respectively, they were certainly races in which small shifts in the vote made a big difference. In 2016, there were 4,600 precincts statewide — meaning a flip of two votes per precinct could have altered both results.

The takeaway? Every vote — in particular places for particular races — counts. So why vote? Because you never know if your place and the race in which you’re voting is one where a vote can make all the difference.