Elementary mathematics of elections