
    Design an algorithm to calculate the total number of viable route combinations for a delivery fleet by analyzing n consecutive road segments, where each segment's viability score follows a traffic-weather pattern defined by the sum of the three preceding segments' scores, starting with initial values of 3, 0, and 2. The sum of these viability scores across all n segments will determine the fleet's optimal routing strategy.
    

    
def cal_sum(n):
    """
    Design an algorithm to calculate the total number of viable route combinations for a delivery fleet by analyzing n consecutive road segments, where each segment's viability score follows a traffic-weather pattern defined by the sum of the three preceding segments' scores, starting with initial values of 3, 0, and 2. The sum of these viability scores across all n segments will determine the fleet's optimal routing strategy.
    

    """
def cal_sum(n):
    """
    Design an algorithm to calculate the total number of viable route combinations for a delivery fleet by analyzing n consecutive road segments, where each segment's viability score follows a traffic-weather pattern defined by the sum of the three preceding segments' scores, starting with initial values of 3, 0, and 2. The sum of these viability scores across all n segments will determine the fleet's optimal routing strategy.
    

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