
    Design a function for the automated grading system that calculates the total score of a student's mathematical assessment by summing up the first n terms of a special scoring sequence, where each term is determined by the sum of the values from three positions before it, starting with the initial values of 3, 0, and 2. The scoring sequence follows the pattern where each subsequent term is calculated as P(n) = P(n-3) + P(n-2), and the system uses this cumulative score to evaluate the student's understanding of recursive mathematical patterns.
    

    
def cal_sum(n):
    """
    Design a function for the automated grading system that calculates the total score of a student's mathematical assessment by summing up the first n terms of a special scoring sequence, where each term is determined by the sum of the values from three positions before it, starting with the initial values of 3, 0, and 2. The scoring sequence follows the pattern where each subsequent term is calculated as P(n) = P(n-3) + P(n-2), and the system uses this cumulative score to evaluate the student's understanding of recursive mathematical patterns.
    

    """
def cal_sum(n):
    """
    Design a function for the automated grading system that calculates the total score of a student's mathematical assessment by summing up the first n terms of a special scoring sequence, where each term is determined by the sum of the values from three positions before it, starting with the initial values of 3, 0, and 2. The scoring sequence follows the pattern where each subsequent term is calculated as P(n) = P(n-3) + P(n-2), and the system uses this cumulative score to evaluate the student's understanding of recursive mathematical patterns.
    

    """
    a = 3
    b = 0
    c = 2
    if n == 0:
        return 3
    if n == 1:
        return 3
    if n == 2:
        return 5
    sum = 5
    while n > 2:
        d = a + b
        sum = sum + d
        a = b
        b = c
        c = d
        n = n - 1
    return sum