eolymp
bolt
Try our new interface for solving problems
Problems

Vas`kin track

Vas`kin track

Cat Vasil learned that a neighbor Dima living from it after a number of fences bred mice. Since his farm all the mice he has long been caught, the cat goes on the hunt for the mice to a neighbor, crawling through a hole in the fence. At each site, Vasil, as any cat bred, moved on already laid there trails. In the village of Old Vasyuki, where Vasil, just one street and that stretches along the river, so the cottages are located only on one side of the street. It is known that between any two adjacent areas in the fence is exactly one hole. How many ways Vasil can get to the site of Dima, if you know that Dima live in the area under the number \textbf{k}, and Vasil himself lives in the area under the number \textbf{m}? \includegraphics{https://static.e-olymp.com/content/dd/dd9e0f999405942943a57830b4497abe6c7590d0.gif} \InputFile In a single line are separated by spaces, first the number of houses in the village of \textbf{n}, then the number of area Vasil \textbf{m}, plot number Dima \textbf{k}, and then \textbf{n} numbers indicating the number of paths that lead either to the hole in the fence or from the hole in the fence, or between the holes in the fence neighbors \textbf{i} and \textbf{i}+\textbf{1}. All input data are natural numbers not exceeding \textbf{10}. \OutputFile Single number - the number of different ways to Vasil to get to the desired area for hunting.
Time limit 0.1 seconds
Memory limit 16 MiB
Input example #1
3 2 3 4 5 3
Output example #1
15
Author Анатолий Присяжнюк