
    Design a patient monitoring system that analyzes sequential vital sign thresholds using a specialized medical pattern sequence, where each number in the sequence is derived from the sum of the values from three measurements prior, starting with P(0) = 3, P(1) = 0, and P(2) = 2. Given n consecutive vital sign measurements, calculate the cumulative threshold value to determine if a patient's condition is deteriorating.
    

    
def cal_sum(n):
    """
    Design a patient monitoring system that analyzes sequential vital sign thresholds using a specialized medical pattern sequence, where each number in the sequence is derived from the sum of the values from three measurements prior, starting with P(0) = 3, P(1) = 0, and P(2) = 2. Given n consecutive vital sign measurements, calculate the cumulative threshold value to determine if a patient's condition is deteriorating.
    

    """
def cal_sum(n):
    """
    Design a patient monitoring system that analyzes sequential vital sign thresholds using a specialized medical pattern sequence, where each number in the sequence is derived from the sum of the values from three measurements prior, starting with P(0) = 3, P(1) = 0, and P(2) = 2. Given n consecutive vital sign measurements, calculate the cumulative threshold value to determine if a patient's condition is deteriorating.
    

    """
    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