#K82907. Nested List Sum

    ID: 36079 Type: Default 1000ms 256MiB

Nested List Sum

Nested List Sum

Given a JSON formatted nested list of integers, compute the recursive sum of all integers. The list may contain other nested lists, and the nesting can be arbitrarily deep. You are required to write a program that reads the nested list from stdin in JSON format and outputs the computed sum to stdout.

Let \(L\) be a nested list defined as either an integer or a list of nested lists. The recursive formula is given by: \[ \text{nested\_sum}(L) = \begin{cases} L, & \text{if } L \text{ is an integer} \\ \sum_{x \in L} \text{nested\_sum}(x), & \text{if } L \text{ is a list} \end{cases} \]

Your solution must handle edge cases including empty lists and deeply nested structures.

inputFormat

The input consists of a single line which is a JSON array representing the nested list. The list may contain integers and other lists. You can assume that the input is always a valid JSON array.

outputFormat

Output a single integer which represents the sum of all integers in the nested list.

## sample
[1, 2, 3, 4, 5]
15