Problem:

Calculating the sum of the last n numbers in List1 (column A) for each value of N in column B.

Solution:

Use the SUM, OFFSET, and COUNTA functions as shown in the following formula:
=SUM(OFFSET($A$2,COUNTA($A$2:$A$7)-1,0,-B2))