In reply to sk7799:
The sum() array reduction method sums up all the elements or sums up whatever is inside the with() clause. You can think of
array.sum() the same as
array.sum with (item), and
item gets replaced with each element. You should look at this.
Your last $display statement references s1, which does not exist your example, and tries to print “Square of array” which has nothing to do with anything in this discussion, so I assumed you had pasted from some other example. You should at least get your code compiling and executing. Then focus on getting the correct results.
N=15 was just the larges value I get get a result with using the tools on EDAPlayground.