J, 23 chars = (+/@(2 3 4 1&*@(+<./))) Example: test =. 3 5 4 3 (+/@(2 3 4 1&*@(+<./))) test 70 [Try it here.][1] [1]: http://tryj.tk/