Score a game of Bowling Your task is to sum up and output one player's score in a game of 10-pin bowling after up to 21 rolls.

The rolls are represented as a sequence of integers in your preferred method of input.
Each integer corresponds to the number of pins that were knocked down in that roll.

Scoring

After each round the number of pins knocked down in that round is counted into the final score.
If a player knocks down all ten pins in the first roll of a round, this is a strike, and the round is over.
Otherwise, the round lasts for one more roll. If the second roll of a round knocks down all the remaining pins, this is a spare.

For each strike there is a bonus equal to the sum of pins knocked down in the two next rolls.
For each spare there is a bonus equal to the number of pins knocked down in the next roll.

The 10th and final round, the player may be granted extra rolls:
In case of a strike, the player gets two more rolls to make up his strike bonus.
In case of a spare, the player gets one more roll.

Examples

Input: 4 3 8 2 7 1 10 7 3 0 10 2 2 10 10 5 4
Output: 131

Input: 10 10 9 1 7 3 2 7 10 1 9 10 7 1 10 10 10
Output: 183


Rules


You may assumed that the input is valid.
As per Mego's comment I have loosened the requirements for the input/output methods to meet our current standard.
Answers in languages that are newer than the challenge are allowed
Shortest code wins!
GolfScript, 50 41 characters
~0]-1%~0{\.9&gt;{+1$3$}{@+.9&gt;3$*}if++}10*p];

Another attempt in GolfScript (run it online).
An explanation of the code follows. The solution utilises the stack nature of the problem (consume rolls one after another) but therefore the input has to be reversed.
~0          # Take the input and evaluate to single numbers on the stack. Add zero.
]-1%~       # Reverse the stack (make array, reverse array, dump array)

0           # Start with a sum of zero
{           # Perform this block 10 times (once for each round)
  \         #   Take the next roll
  .9&gt;{      #   If it is a strike
    +       #     Add the value of the roll to the sum
    1$3$    #     and duplicate top two members of the stack (i.e. next two rolls).
  }{        #   ... else ...
    @+      #     Take the next roll and add with first roll in round.
    .9&gt;     #     Does this sum show a spare?
    3$*     #     Get next roll (potential bonus) and multiply with yes/no.
            #     Since we pushed an additional 0 in the beginning 
            #     there is a spare roll even for the last round.
  }if       #   endif
  ++        #   Add top three stack entries together
            #   (i.e. sum+2 bonus rolls for strike, sum+rolls+bonus else)
}10*        # Loop ten times

p];         # Sum is top of stack. Print sum and discard any leftover rolls.

Previous version:
~].1&gt;.1&gt;]zip{((.10&lt;{@(0=@+@1&gt;1$9&gt;&lt;}*@}10*;]{+}.@**