Matched Brackets ZCO12001

here when i use the custom input with the default items used in the example provided i get a valid solution , however when i run it without the custom input it does not , after some verification , it read N as 0 while it is in the statement that n cannot be 0 , can someone help ?
‘’’’

‘’’’