From Wikipedia():

The Elo rating system is a method for calculating the relative skill levels of players in competitor-versus-competitor games such as chess. It is named after its creator Arpad Elo, a Hungarian-born American physics professor.
The Elo system was originally invented as an improved chess rating system but is also used as a rating system for multiplayer competition in a number of video games, association football, gridiron football, basketball,Major League Baseball, competitive programming, Magic: The Gathering, esports, and other games.
The difference in the ratings between two players serves as a predictor of the outcome of a match. Two players with equal ratings who play against each other are expected to score an equal number of wins. A player whose rating is 100 points greater than their opponent's is expected to score 64%; if the difference is 200 points, then the expected score for the stronger player is 76%.
A player's Elo rating is represented by a number which increases or decreases based upon the outcome of games between rated players. After every game, the winning player takes points from the losing one. The difference between the ratings of the winner and loser determines the total number of points gained or lost after a game. In a series of games between a high-rated player and a low-rated player, the high-rated player is expected to score more wins. If the high-rated player wins, then only a few rating points will be taken from the low-rated player. However, if the lower rated player scores an upset win, many rating points will be transferred. The lower rated player will also gain a few points from the higher rated player in the event of a draw. This means that this rating system is self-correcting. A player whose rating is too low should, in the long run, do better than the rating system predicts, and thus gain rating points until the rating reflects their true playing strength.

The Cityliga Elo rating system was adjusted in a way, to work with multiple opponents at once, as it is the case in a race with multiple drivers. How the change of Elo rating is calculated after each race, you see below.

Who is in "n"?

In the current implementation of Cityliga Elo, every driver who started a race, is in the variable "n". So if a driver did not finish his race, because of a crash or network problems for example, he will be scored at the bottom and probably lose Elo rating.

What happens to newcomers?

Driver, who finished their very first race, can not be processed immediately, since they have no Elo rating yet. Therefore, they get the average elo rating of all the drivers in the grid they started as their initial Elo rating. Based on that rating, the change in Elo rating is calculated as shown above. The very first drivers in this system, so the drivers for the very first race processed by the Elo rating, got an initial Elo rating of 1000 points.

How are the races weights "x"?

For events, where only one long race, the variable "x" is 1. For events with two or three shorter races, the variable "x" is 0.5 or 0.33 per race. In events, where the grid is split up and drive in four races in a knock out round manner, the variable "x" is also 0.5, because each driver drives two races.