{"raw_statement":[{"iden":"problem statement","content":"> Takahashi is trying to create a game inspired by baseball, but he is having difficulty writing the code.  \n> Write a program for Takahashi that solves the following problem.\n\nThere are $4$ squares called Square $0$, Square $1$, Square $2$, and Square $3$. Initially, all squares are empty.  \nThere is also an integer $P$; initially, $P = 0$.  \nGiven a sequence of positive integers $A = (A_1, A_2, \\dots, A_N)$, perform the following operations for $i = 1, 2, \\dots, N$ in this order:\n\n1.  Put a piece on Square $0$.\n2.  Advance every piece on the squares $A_i$ squares ahead. In other words, if Square $x$ has a piece, move the piece to Square $(x + A_i)$.  \n    If, however, the destination square does not exist (i.e. $x + A_i$ is greater than or equal to $4$) for a piece, remove it. Add to $P$ the number of pieces that have been removed.\n\nPrint the value of $P$ after all the operations have been performed."},{"iden":"constraints","content":"*   $1 \\leq N \\leq 100$\n*   $1 \\leq A_i \\leq 4$\n*   All values in input are integers."},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$N$\n$A_1$ $A_2$ $\\dots$ $A_N$"},{"iden":"sample input 1","content":"4\n1 1 3 2"},{"iden":"sample output 1","content":"3\n\nThe operations are described below. After all the operations have been performed, $P$ equals $3$.\n\n*   The operations for $i=1$:\n    1.  Put a piece on Square $0$. Now, Square $0$ has a piece.\n    2.  Advance every piece on the squares $1$ square ahead. After these moves, Square $1$ has a piece.\n*   The operations for $i=2$:\n    1.  Put a piece on Square $0$. Now, Squares $0$ and $1$ have a piece.\n    2.  Advance every piece on the squares $1$ square ahead. After these moves, Squares $1$ and $2$ have a piece.\n*   The operations for $i=3$:\n    1.  Put a piece on Square $0$. Now, Squares $0$, $1$, and $2$ have a piece.\n    2.  Advance every piece on the squares $3$ squares ahead.  \n        Here, for the pieces on Squares $1$ and $2$, the destination squares do not exist (since $1+3=4$ and $2+3=5$), so remove these pieces and add $2$ to $P$. $P$ now equals $2$. After these moves, Square $3$ has a piece.\n*   The operations for $i=4$:\n    1.  Put a piece on Square $0$. Now, Squares $0$ and $3$ have a piece.\n    2.  Advance every piece on the squares $2$ squares ahead.  \n        Here, for the piece on Square $3$, the destination square does not exist (since $3+2=5$), so remove this piece and add $1$ to $P$. $P$ now equals $3$.  \n        After these moves, Square $2$ has a piece."},{"iden":"sample input 2","content":"3\n1 1 1"},{"iden":"sample output 2","content":"0\n\nThe value of $P$ may not be updated by the operations."},{"iden":"sample input 3","content":"10\n2 2 4 1 1 1 4 2 2 1"},{"iden":"sample output 3","content":"8"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}