#P1147A. Hide and Seek
Hide and Seek
Description
Alice and Bob are playing a game on a line with cells. There are cells labeled from through . For each from to , cells and are adjacent.
Alice initially has a token on some cell on the line, and Bob tries to guess where it is.
Bob guesses a sequence of line cell numbers in order. In the -th question, Bob asks Alice if her token is currently on cell . That is, Alice can answer either "YES" or "NO" to each Bob's question.
At most one time in this process, before or after answering a question, Alice is allowed to move her token from her current cell to some adjacent cell. Alice acted in such a way that she was able to answer "NO" to all of Bob's questions.
Note that Alice can even move her token before answering the first question or after answering the last question. Alice can also choose to not move at all.
You are given and Bob's questions . You would like to count the number of scenarios that let Alice answer "NO" to all of Bob's questions.
Let denote a scenario where Alice starts at cell and ends at cell . Two scenarios and are different if or .
The first line contains two integers and () — the number of cells and the number of questions Bob asked.
The second line contains integers () — Bob's questions.
Print a single integer, the number of scenarios that let Alice answer "NO" to all of Bob's questions.
Input
The first line contains two integers and () — the number of cells and the number of questions Bob asked.
The second line contains integers () — Bob's questions.
Output
Print a single integer, the number of scenarios that let Alice answer "NO" to all of Bob's questions.
Note
The notation denotes a scenario where Alice starts at cell and ends at cell .
In the first example, the valid scenarios are . For example, is valid since Alice can start at cell , stay there for the first three questions, then move to cell after the last question.
is valid since Alice can start at cell , stay there for the first question, the move to cell for the next two questions. Note that is only counted once, even though there are different questions that Alice can choose to do the move, but remember, we only count each pair of starting and ending positions once.
In the second example, Alice has no valid scenarios.
In the last example, all where except for are valid scenarios.