I am curious if there is a way of somehow recreating such code as a math statement.
S = [1,2,3,4]
output = 0
for x in S:
N = S.copy()
N[x-1] = 0
for y in N:
output = output + y
The only thing that I could think of is reminiscent of something like this, but I have no clue how I could change the numbers in the second array, nor how to duplicate the array. $$\sum_{x \in S}{\sum_{y \in N}{y}}$$
The solution is 30. ( 0+2+3+4+1+0+3+4+1+2+0+4+1+2+3+0)