






import functools




def       _SCREAMING_SNAKE_CASE (							__snake_case   ,      __snake_case )				->						int:

       # Validation
       if not isinstance(__snake_case   ,      __snake_case ) or not all(isinstance(__snake_case   ,      __snake_case ) for day in days ):
              raise ValueError("""The parameter days should be a list of integers""" )

       if len(__snake_case ) != 3 or not all(isinstance(__snake_case   ,      __snake_case ) for cost in costs ):
              raise ValueError("""The parameter costs should be a list of three integers""" )

       if len(__snake_case ) == 0:
              return 0

       if min(__snake_case ) <= 0:
              raise ValueError("""All days elements should be greater than 0""" )

       if max(__snake_case ) >= 3_6_6:
              raise ValueError("""All days elements should be less than 366""" )

       _UpperCAmelCase							=    set(__snake_case )

       @functools.cache
       def dynamic_programming(__snake_case ) -> int:
              if index > 3_6_5:
                     return 0

              if index not in days_set:
                     return dynamic_programming(index + 1 )

              return min(
                  costs[0] + dynamic_programming(index + 1 )   ,      costs[1] + dynamic_programming(index + 7 )   ,      costs[2] + dynamic_programming(index + 3_0 )   ,      )

       return dynamic_programming(1 )


if __name__ == "__main__":
  import doctest

  doctest.testmod()



def      UpperCAmelCase__		(UpperCamelCase_ = 10_00							):



     """simple docstring"""






     return sum(2 * a * ((a - 1) // 2) for a in range(3				,n + 1							)							)


if __name__ == "__main__":
 print(solution())




