StickStack is a very simple stack-based programming language with only two instructions:
|pushes the length of the stack onto the stack
-pops the top two elements from the stack and pushes back their difference (
second topmost - topmost)
- The stack is empty at the start of the program.
- All instructions are executed sequentially from left to right.
- If there are less than 2 numbers on the stack the
-instruction is illegal.
- At the end of the execution the stack should contain exactly one number.
Any integer can be generated by a StickStack program. For example:
|||--||-- generates the number 2 through the following stack states:   [0, 1] [0, 1, 2] [0, -1]  [1, 1] [1, 1, 2] [1, -1] 
To evaluate your StickStack code you can use this online (CJam) evaluator. (Thanks for @Martin for the code.)
You should write a program or function which given an integer number as input outputs or returns a string representing a StickStack program which outputs the given number.
- Your primary score is the total length of the StickStack programs for the below given test cases. Lower score is better.
- Your submission is valid only if you ran your program on all the test cases and counted your score.
- Your secondary (tiebreaker) score is the length of your generating program or function.
Input test cases
(Each number is a different test case.)
-8607 -6615 -6439 -4596 -4195 -1285 -72 12 254 1331 3366 3956 5075 5518 5971 7184 7639 8630 9201 9730
Your program should work for any integers (which your data-type can handle) not just for the given test cases. The solutions for the test numbers should not be hardcoded into your program. If there will be doubt of hardcoding the test numbers will be changed.