J, <s>23</s> 22 chars = (+/ .*&2 3 4 1@(+<./)) Example: test =. 3 5 4 3 (+/ .*&2 3 4 1@(+<./)) test 70 [Try it here.][1] (23 long explicit function definition: `v=:3 :'+/+/\.3|.y+<./y'`) [1]: http://tryj.tk/