This math trick is called Hummer’s Poker Chip Trick.
The trick uses six poker chips with a number on both sides – the table below shows the values on each for the poker chips. Note 5 is on two different chips.
The sides can be denoted by two different colors such as red/green or bold/regular font or some other method as long as you can determine the side.

side 1:    0    1    2    3    4    5
side 2:    5    6    7    8    9   10

Start by asking the spectator to shuffle chips and place the six on table in two rows, such as (green and red denote sides of the chip):
5   2   9
8  10
Magician turns their back to the chips and spectator turns over any 3 chips. In this example we will assume row 1: chips 1 and 3 and row 2: chip 2 are turned over.
0   2   4
10
With Magician back still to the chips he asks the spectator to turn over some chips.
The magician remembers the position of the red numbered chips when they were first positioned.
He asks for each of the red numbered chips in the original set to be turned over. In the example the magician asks for chips 1 and 3 in row 1 to be turned over and chips 2 and 3 in row 2 to be turned over resulting in:
5   2   9
8   5
In the last step the spectator turns over any 3 chips and covers the chip with a small piece of paper so the number cannot be seen (underlined number represents a chip turned over and now hidden chip).
0   7  9
6   8  5
At this point the magician turns around and give the sum of 3 the hidden chips.
In his head the magician calculates:
R = # red chips showing; in this case 2 (9 and 8)

S = sum of exposed chips; 22 in this case (0 + 9 + 8 + 5)

Uses this formula to calculate the sum of the 3 hidden chips:

(10*R + 15) – S = (10*2 + 15) – 22 = 35 – 22 = 13 which is the sum of the hidden chips (0 + 7 + 6)

This is a very cool math trick, one of my favorites. At first it looks as if the math behind the trick is pretty easy but at least for me it took a bit of thinking to be able to explain why this method always works.

Analysis of mathematics behind the trick
Examples: (underlined number indicates it is hidden).
Below are 5 example sets on the 4 steps in the trick.
1. Initial – starting arrangement of the chips.
2. Flip 3 – Spectator flips over any 3 chips.
3. Flip initial Red – Magician asks for any chip which remembered were red in the initial arrangement to be turned over.
4. Flip & Hide 3 – spectator flips over and hides any 3 chips.
Initial Flip 3 Flip Initial Red Flip & Hide 3
0 1 2 5 1 2 5 1 2 0 1 2
3 4 5 8 9 5 8 9 5 3 4 5
5 4 8 10 4 3 10 4 8 10 9 3
0 6 2 0 1 2 0 6 2 0 6 7
10 5 7 10 0 2 5 5 7 5 0 2
4 3 6 4 8 6 4 8 1 4 3 1
10 5 7 10 0 2 5 5 7 5 5 7
4 3 6 4 8 6 4 8 1 9 3 6
10 5 7 10 5 7 5 0 2 10 5 7
4 3 6 9 8 1 9 8 6 9 8 6

In step 2 the spectator can only flip 3 chips. To understand the mathematics behind the formula we need to look at the relationship between Step 2 and Step 3 (there is a relationship between them).

Rules we can state:
In step 3 we can have the following scenarios and state of chip at the end of step 3:

1. A Red chip in the step 1 and NOT flipped in step 2 by the spectator will be Black at end of step 3.
2. A Red chip in the step 1 and flipped in step 2 by the spectator will be Red (max of 3 since only 3 chips can be flipped) at end of step 3.
3. A Black chip in step 1 NOT flipped in step 2 will be Black at end of step 3.
4. A Black in step 1 flipped in step 2 will be Red at end of step 3.

Therefore: The table below shows the number of possible Red and Black (color in initial arrangement of step 1) chips flipped in Step 2 and the resulting Red in step 3 (using the 4 rules we just listed):

Actions in Step 2 1 2 3  4
# RED flipped in step 2 0 1 2 3
# Black flipped in step 2 3 2 1 0
Resulting # of Red in Step 3 3 3 3 3

In the table note in column labeled 2: If we flip 1 in step 2 which was Red in step 1 that means we flipped 2 Black (must flip 3 chips) and thus will have 2 Black at the end of step 3.  See rules 2 and 4.
The other columns show all other possible scenarios.

At step 3, with 3 Red, the total for the six numbers is 30.
The logic for this is the following:
If we have only Black side chips showing the total of all of them is 15 (0 + 1 + 2 + 3 + 4 + 5). Since we know we have 3 Red chips showing and a Red chip is 5 more than its corresponding Black side we need to add 3*5 = 15 to the total for a grand total of 30 when we have 3 Red chips showing.

Last step will turn over 3 and hide them.
Look at number of Red showing, name it R.

Then 3 – R are number of Black(low) showing – we know this since there had to have been 3 Red at the end of step 3.

Since we started with 3 Red from step 3 and R are showing then 3 – R were turned over and hidden in the last step then we will have:

R Black are hidden (3 – R are number of Red turned over and thus become Black).

Thus we have R Red hidden (3 – (3-R) = 3 -3 + R = R.

So total Red showing in last step is R + R = 2R and sum of values of all chips turned up for last step is (hidden and showing):

15 + 2R*5 = 15 + 10R

And total of sum of values of the hidden chips is = 15 + 10R – (total value of chips showing).