
    Design an algorithm for a patient monitoring system that analyzes heart rhythm patterns by calculating the sum of consecutive vital sign measurements following a specific progression sequence, where each new measurement is determined by the relationship Vn = Vn-3 + Vn-2, with initial values V(0) = 3, V(1) = 0, and V(2) = 2. Given n consecutive measurements, calculate the total sum of these values to help identify potential cardiac irregularities.
    

    
def cal_sum(n):
    """
    Design an algorithm for a patient monitoring system that analyzes heart rhythm patterns by calculating the sum of consecutive vital sign measurements following a specific progression sequence, where each new measurement is determined by the relationship Vn = Vn-3 + Vn-2, with initial values V(0) = 3, V(1) = 0, and V(2) = 2. Given n consecutive measurements, calculate the total sum of these values to help identify potential cardiac irregularities.
    

    """
def cal_sum(n):
    """
    Design an algorithm for a patient monitoring system that analyzes heart rhythm patterns by calculating the sum of consecutive vital sign measurements following a specific progression sequence, where each new measurement is determined by the relationship Vn = Vn-3 + Vn-2, with initial values V(0) = 3, V(1) = 0, and V(2) = 2. Given n consecutive measurements, calculate the total sum of these values to help identify potential cardiac irregularities.
    

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