Here is one possible way to achieve your goal. First, start by creating this Sub in VBA (Press Alt+F11, right click "ThisWorkbook", Insert > Module, then copy and paste the following):
Function ColorSum(CellColor As Range) ColorSum = CellColor.Interior.ColorIndex
Next, create a new column in column C named ColorSum. In cell C2 put the formula =ColorSum(A2) and copy this formula down to C6. You should get values of 23, 40, 40, 50, 50 in cells C2:C6, respectively.
Finally, in cells B8:B10 put the following formulas:
Now, I must warn you that this solution is set up specifically to solve the problem the way you have it designed. If you change the colors of cells A2:A6, or add more cells to the list, this solution may not work for you (i.e. it is not dynamic).