Math with commands

There are 2 players, each selects a number between 1-10, the player with the higher number gets as many points at the difference between the 2 selected numbers are.

I have some idea how to go about this, but Im not 100% sure. I think I start by having a scoreboard for each player, setting it to the number they selected. Then I use the "if score" command to compare them... From here on, im kinda lost. How exactly should I find the difference between them and keep track of the total points?

Continue to help post