Alice and Bob are playing a game on a line with $n$ cells. There are $n$ cells labeled from $1$ through $n$. For each $i$ from $1$ to $n-1$, cells $i$ and $i+1$ 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 $x_1, x_2, \ldots, x_k$ in order. In the $i$-th question, Bob asks Alice if her token is currently on cell $x_i$. 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 $n$ and Bob's questions $x_1, \ldots, x_k$. You would like to count the number of scenarios that let Alice answer "NO" to all of Bob's questions. 

Let $(a,b)$ denote a scenario where Alice starts at cell $a$ and ends at cell $b$. Two scenarios $(a_i, b_i)$ and $(a_j, b_j)$ are different if $a_i \neq a_j$ or $b_i \neq b_j$.


-----Input-----

The first line contains two integers $n$ and $k$ ($1 \leq n,k \leq 10^5$) — the number of cells and the number of questions Bob asked.

The second line contains $k$ integers $x_1, x_2, \ldots, x_k$ ($1 \leq x_i \leq n$) — Bob's questions.


-----Output-----

Print a single integer, the number of scenarios that let Alice answer "NO" to all of Bob's questions.


-----Examples-----
Input
5 3
5 1 4

Output
9

Input
4 8
1 2 3 4 4 3 2 1

Output
0

Input
100000 1
42

Output
299997



-----Note-----

The notation $(i,j)$ denotes a scenario where Alice starts at cell $i$ and ends at cell $j$.

In the first example, the valid scenarios are $(1, 2), (2, 1), (2, 2), (2, 3), (3, 2), (3, 3), (3, 4), (4, 3), (4, 5)$. For example, $(3,4)$ is valid since Alice can start at cell $3$, stay there for the first three questions, then move to cell $4$ after the last question. 

$(4,5)$ is valid since Alice can start at cell $4$, stay there for the first question, the move to cell $5$ for the next two questions. Note that $(4,5)$ 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 $(i,j)$ where $|i-j| \leq 1$ except for $(42, 42)$ are valid scenarios.

Source: codeforces | Difficulty: MEDIUM
Tags: Graph algorithms


Solutions:
(n, m) = map(int, input().split(' '))
s = list(map(int, input().split(' ')))
l = {i: m for i in range(n)}
r = {i: -1 for i in range(n)}
for (i, a) in enumerate(s):
	l[a - 1] = min(i, l[a - 1])
	r[a - 1] = max(i, r[a - 1])
count = 0
for i in range(n):
	for j in range(3):
		a = i
		b = i + j - 1
		if b < 0 or b == n:
			continue
		if l[a] > r[b]:
			count += 1
print(count)


import io, sys, atexit, os
import math as ma
from sys import exit
from decimal import Decimal as dec
from itertools import permutations
from random import randint as rand

def li():
	return list(map(int, input().split()))

def num():
	return map(int, input().split())

def nu():
	return int(input())

def find_gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def lcm(x, y):
	gg = find_gcd(x, y)
	return x * y // gg
mm = 1000000007
yp = 0

def solve():
	t = 1
	for _ in range(t):
		(n, k) = num()
		a = li()
		xp = [99999999] * (n + 1)
		op = [-1] * (n + 1)
		for i in range(k):
			xp[a[i]] = min(i, xp[a[i]])
			op[a[i]] = max(op[a[i]], i)
		cc = 0
		for i in range(1, n + 1):
			if op[i] == -1:
				cc += 1
			if i + 1 <= n:
				if op[i + 1] == -1:
					cc += 1
				elif op[i + 1] < xp[i]:
					cc += 1
			if i - 1 > 0:
				if op[i - 1] == -1:
					cc += 1
				elif op[i - 1] < xp[i]:
					cc += 1
		print(cc)
solve()


import sys
input = sys.stdin.readline
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
post = []
ok1 = []
ok2 = []
for i in range(n):
	post.append(0)
	ok1.append(0)
	ok2.append(0)
ok1[n - 1] = 1
ok2[0] = 1
count = 0
for i in range(k - 1, -1, -1):
	post[arr[i] - 1] = 1
	if arr[i] < n and post[arr[i]] == 1:
		ok1[arr[i] - 1] = 1
	if arr[i] > 1 and post[arr[i] - 2] == 1:
		ok2[arr[i] - 1] = 1
count += 2 * n - sum(ok1) - sum(ok2)
for i in range(n):
	if post[i] == 0:
		count += 1
print(count)


(n, m) = map(int, input().split())
guesses = list(map(int, input().split()))
possible = 3 * n - 2
indexes = {}
for i in range(m):
	if guesses[i] not in indexes:
		indexes[guesses[i]] = [i]
	else:
		indexes[guesses[i]].append(i)
for i in indexes.keys():
	possible -= 1
	status = 0
	if i + 1 in indexes:
		for j in indexes[i]:
			for k in indexes[i + 1]:
				if k > j:
					status = -1
					possible -= 1
					break
			if status == -1:
				break
	status = 0
	if i - 1 in indexes:
		for j in indexes[i]:
			for k in indexes[i - 1]:
				if k > j:
					possible -= 1
					status = -1
					break
			if status == -1:
				break
print(possible)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
p = [-1] * (n + 1)
s = [-1] * (n + 1)
for i in range(k):
	if p[a[i]] == -1:
		p[a[i]] = i
for i in range(k - 1, -1, -1):
	if s[a[i]] == -1:
		s[a[i]] = i
count = 0
for i in range(1, n + 1):
	if p[i] == -1:
		if i == 1 or i == n:
			count += 2
			continue
		count += 3
	else:
		if i != n and (s[i + 1] == -1 or s[i + 1] < p[i]):
			count += 1
		if i != 1 and (s[i - 1] == -1 or s[i - 1] < p[i]):
			count += 1
print(count)


def solve():
	(n, k) = map(int, input().split())
	x = list(map(int, input().split()))
	fpos = [k for i in range(n + 1)]
	lpos = [-1 for i in range(n + 1)]
	for i in range(1, k + 1):
		lpos[x[i - 1]] = i
	for i in range(k, 0, -1):
		fpos[x[i - 1]] = i
	ans = 0
	for i in range(1, n + 1):
		if lpos[i] == -1:
			ans += 1
	for i in range(1, n):
		if fpos[i] >= lpos[i + 1]:
			ans += 1
		if fpos[i + 1] >= lpos[i]:
			ans += 1
	print(ans)

def __starting_point():
	solve()
__starting_point()


(n, k) = map(int, input().split())
x = [int(x) - 1 for x in input().split()]
total = [0 for _ in range(n + 1)]
primero = [99999999999999999 for _ in range(n + 1)]
ultimo = [-1 for _ in range(n + 1)]
for (i, v) in enumerate(x):
	primero[v] = min(i, primero[v])
	ultimo[v] = max(i, ultimo[v])
	total[v] += 1
sol = 0
if total[n - 1] == 0:
	sol = 1
for i in range(n - 1):
	if total[i] == 0:
		sol += 1
	if primero[i] > ultimo[i + 1]:
		sol += 1
	if primero[i + 1] > ultimo[i]:
		sol += 1
print(sol)


def main():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	ret = 3 * n - 2
	(s1, s2) = (set(), set())
	for x in a:
		if x - 1 in s1:
			s2.add((x - 1, x))
		if x + 1 in s1:
			s2.add((x + 1, x))
		s1.add(x)
	ret = ret - len(s1) - len(s2)
	print(ret)
main()


(n, k) = map(int, input().split())
d = list(map(int, input().split()))
u = [False for i in range(n)]
dic = {}
for (p, i) in enumerate(d):
	if dic.get(i) == None:
		dic[i] = [p]
	else:
		dic[i].append(p)
r = 3 * n - 2
for (p, i) in enumerate(d):
	if u[i - 1] == True:
		continue
	if dic.get(i) != None and dic[i][-1] >= p:
		r -= 1
	if dic.get(i + 1) != None and dic[i + 1][-1] > p:
		r -= 1
	if dic.get(i - 1) != None and dic[i - 1][-1] > p:
		r -= 1
	u[i - 1] = True
print(r)


(n, k) = map(int, input().split())
x = [True] * (3 * n)
for v in map(int, input().split()):
	v -= 1
	if x[3 * v + 1]:
		x[3 * v + 1] = False
	if v > 0 and (not x[3 * v - 2]):
		x[3 * v - 1] = False
	if v < n - 1 and (not x[3 * v + 4]):
		x[3 * v + 3] = False
print(sum(x) - 2)


def main():
	(n, k) = map(int, input().split())
	x = list(map(int, input().split()))
	res = 3 * n - 2
	if n == 1:
		print(0)
		return 0
	ways = [[None, 1, 2]]
	for i in range(2, n):
		ways.append([i - 1, i, i + 1])
	ways.append([n - 1, n, None])
	for i in range(k):
		if ways[x[i] - 1][1] != None:
			ways[x[i] - 1][1] = None
			res -= 1
		if x[i] > 1:
			if ways[x[i] - 2][1] == None:
				if ways[x[i] - 2][2] != None:
					ways[x[i] - 2][2] = None
					res -= 1
		if x[i] < n:
			if ways[x[i]][1] == None:
				if ways[x[i]][0] != None:
					ways[x[i]][0] = None
					res -= 1
	print(res)
main()


(n, k) = [int(i) for i in input().strip().split(' ')]
X = [int(i) for i in input().strip().split(' ')]
adj = [[] for _ in range(n + 1)]
for (i, cell) in enumerate(X):
	if cell not in adj[cell]:
		adj[cell] += [cell]
	if cell > 1:
		if adj[cell - 1]:
			if (cell - 1, cell) not in adj[cell - 1]:
				adj[cell - 1] += [(cell - 1, cell)]
			if (cell - 1, cell) not in adj[cell]:
				adj[cell] += [(cell - 1, cell)]
	if cell < n:
		if adj[cell + 1]:
			if (cell + 1, cell) not in adj[cell + 1]:
				adj[cell + 1] += [(cell + 1, cell)]
			if (cell + 1, cell) not in adj[cell]:
				adj[cell] += [(cell + 1, cell)]
count = 0
for c in range(1, n + 1):
	if not adj[c]:
		count += 3 if 1 < c < n else 2
	else:
		if 1 < c:
			if (c - 1, c) not in adj[c]:
				count += 1
		if c < n:
			if (c + 1, c) not in adj[c]:
				count += 1
print(count)


def ck(p, q):
	return 1 if bpos[p] > fpos[q] else 0
(n, k) = map(int, input().split())
x = list(map(int, input().split()))
fpos = [-1 for i in range(100001)]
bpos = [k + 5 for i in range(100001)]
for i in range(k):
	fpos[x[i]] = i
	bpos[x[k - 1 - i]] = k - 1 - i
ans = ck(n, n)
for i in range(1, n):
	ans += ck(i, i) + ck(i, i + 1) + ck(i + 1, i)
print(ans)


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
import threading
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
(n, k) = map(int, input().split())
first = [-1] * n
last = [-1] * n
a = list(map(int, input().split()))
for i in range(k):
	last[a[i] - 1] = i
	if first[a[i] - 1] == -1:
		first[a[i] - 1] = i
c = 0
for i in range(n):
	if first[i] == -1:
		c += 1
	if i != n - 1:
		if first[i + 1] >= last[i] or first[i + 1] == -1:
			c += 1
	if i != 0:
		if first[i - 1] >= last[i] or first[i - 1] == -1:
			c += 1
print(c)


(N, cnt) = [int(100000.0 + 5000), int(0)]

class edg:
	(pnt, nxt) = [int(0), int(0)]
fir = [0] * N
ed = [edg()]
for i in range(1, N):
	ed.append(edg())

def link(u, v):
	global cnt
	cnt += 1
	ed[cnt].nxt = fir[u]
	fir[u] = cnt
	ed[cnt].pnt = v
(n, k) = list(map(int, input().split(' ')))
q = [0] + list(map(int, input().split(' ')))
for i in range(1, k + 1):
	(u, v) = [q[i], i]
	link(u, v)
ans = int(0)
for i in range(1, n + 1):
	if fir[i] == 0:
		ans += 1
for i in range(2, n + 1):
	(minx, maxx) = [1 << 27, -(1 << 27)]
	u = i
	e = fir[u]
	while e != 0:
		minx = min(minx, ed[e].pnt)
		e = ed[e].nxt
	u = i - 1
	e = fir[u]
	while e != 0:
		maxx = max(maxx, ed[e].pnt)
		e = ed[e].nxt
	if minx > maxx:
		ans += 1
for i in range(1, n):
	(minx, maxx) = [1 << 27, -(1 << 27)]
	u = i
	e = fir[u]
	while e != 0:
		minx = min(minx, ed[e].pnt)
		e = ed[e].nxt
	u = i + 1
	e = fir[u]
	while e != 0:
		maxx = max(maxx, ed[e].pnt)
		e = ed[e].nxt
	if minx > maxx:
		ans += 1
print(ans)


intin = lambda : map(int, input().split())
Ain = lambda : list(map(int, input().split()))
mod = 1000000007
(n, k) = intin()
a = Ain()
m = n + 1
f = [-1] * m
l = [-1] * m
for i in range(k):
	x = a[i]
	if f[x] == -1:
		f[x] = i
	l[x] = i
ans = 0
for i in range(1, m):
	if f[i] == -1:
		ans += 1
		if i > 1:
			ans += 1
		if i < n:
			ans += 1
		continue
	if i < n and f[i] > l[i + 1]:
		ans += 1
	if i > 1 and f[i] > l[i - 1]:
		ans += 1
print(ans)


from collections import defaultdict
(n, k) = map(int, input().strip().split())
num_dict = defaultdict(int)
nums = [int(i) for i in input().strip().split()]
total = (n - 2) * 3 + 4
visited = set()
two_visited = set()
for i in nums:
	if i not in visited:
		total -= 1
		if i - 1 in visited and (i - 1, i) not in two_visited:
			total -= 1
			two_visited.add((i - 1, i))
		if i + 1 in visited and (i + 1, i) not in two_visited:
			total -= 1
			two_visited.add((i + 1, i))
		visited.add(i)
	else:
		if i - 1 in visited and (i - 1, i) not in two_visited:
			total -= 1
			two_visited.add((i - 1, i))
		if i + 1 in visited and (i + 1, i) not in two_visited:
			total -= 1
			two_visited.add((i + 1, i))
print(total)


def sol(n, q):
	dp = [3] * n
	dp[0] = 2
	dp[-1] = 2
	tmp = set()
	for i in range(len(q) - 1, -1, -1):
		tmp.add(q[i])
		curr = 0
		for adj in [q[i] - 1, q[i] + 1]:
			if 1 <= adj <= n and adj not in tmp:
				curr += 1
		dp[q[i] - 1] = curr
	return sum(dp)
[n, k] = [int(x) for x in input().split()]
q = [int(x) for x in input().split()]
print(sol(n, q))


(n, k) = map(int, input().split())
ls = list(map(int, input().split()))
last = {}
for i in range(k - 1, -1, -1):
	try:
		last[ls[i]] += 0
	except:
		last[ls[i]] = i
_list = []
for i in range(k):
	_list.append(ls[i])
	try:
		if last[ls[i] + 1] > i:
			_list.append((ls[i], ls[i] + 1))
	except:
		pass
	try:
		if last[ls[i] - 1] > i:
			_list.append((ls[i], ls[i] - 1))
	except:
		pass
_list = list(set(_list))
print(3 * n - 2 - len(_list))


import sys
input = lambda : sys.stdin.readline().strip('\r\n')
(n, k) = map(int, input().split())
x = list(map(int, input().split()))
first = [k] * (n + 1)
last = [-1] * (n + 1)
for i in range(1, k + 1):
	last[x[i - 1]] = i
for i in range(k, 0, -1):
	first[x[i - 1]] = i
ans = 0
for i in range(1, n + 1):
	if last[i] == -1:
		ans += 1
for i in range(1, n):
	if first[i] >= last[i + 1]:
		ans += 1
	if first[i + 1] >= last[i]:
		ans += 1
print(ans)


(n, k) = map(int, input().split())
X = list(map(int, input().split()))
X = [x - 1 for x in X]
if n == 1:
	print(0)
	exit()
from collections import defaultdict
First = defaultdict(lambda : k)
Last = defaultdict(lambda : -1)
for (i, x) in enumerate(X):
	First[x] = min(First[x], i)
	Last[x] = max(Last[x], i)
ans = 0
X = set(X)
for a in range(n):
	if a == 0:
		for d in range(0, 2):
			b = a + d
			if a != b:
				if First[a] >= Last[b]:
					ans += 1
			elif a not in X:
				ans += 1
	elif a == n - 1:
		for d in range(-1, 1):
			b = a + d
			if a != b:
				if First[a] >= Last[b]:
					ans += 1
			elif a not in X:
				ans += 1
	else:
		for d in range(-1, 2):
			b = a + d
			if a != b:
				if First[a] >= Last[b]:
					ans += 1
			elif a not in X:
				ans += 1
print(ans)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import *
from operator import itemgetter, attrgetter
from decimal import *
import bisect
import math
import heapq as hq
MOD = 10 ** 9 + 7

def pow(a, b, m):
	ans = 1
	while b:
		if b & 1:
			ans = ans * a % m
		b //= 2
		a = a * a % m
	return ans
vis = []
graph = []

def dfs(v):
	if vis[v]:
		return 0
	vis[v] = True
	temp = 0
	for vv in graph[v]:
		temp += dfs(vv)
	return 1 + temp

def ispalindrome(s):
	if s[:] == s[::-1]:
		return 1
	return 0
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
h = [[10 ** 6, 0] for i in range(n + 2)]
h[n + 1] = [10 ** 7, 10 ** 7]
h[0] = [10 ** 7, 10 ** 7]
for i in range(k):
	h[l[i]][0] = min(h[l[i]][0], i + 1)
	h[l[i]][1] = max(h[l[i]][1], i + 1)
count = 0
for i in range(1, n + 1):
	if h[i] == [10 ** 6, 0]:
		count += 1
	if h[i + 1][1] < h[i][0] or h[i + 1][0] == 10 ** 6:
		count += 1
	if h[i - 1][1] < h[i][0] or h[i - 1][0] == 10 ** 6:
		count += 1
print(count)


import sys

class Main:

	def __init__(self):
		self.buff = None
		self.index = 0

	def next(self):
		if self.buff is None or self.index == len(self.buff):
			self.buff = self.next_line()
			self.index = 0
		val = self.buff[self.index]
		self.index += 1
		return val

	def next_line(self):
		return sys.stdin.readline().split()

	def next_ints(self):
		return [int(x) for x in sys.stdin.readline().split()]

	def next_int(self):
		return int(self.next())

	def solve(self):
		(n, k) = self.next_ints()
		x = self.next_ints()
		cc = [0 for _ in range(0, n + 10)]
		us = [0 for _ in range(0, n + 10)]
		for xx in x:
			cc[xx] += 1
		res = n * 3 - 2
		for xx in x:
			cc[xx] -= 1
			if us[xx] != 0:
				continue
			res -= 1
			us[xx] = 1
			if cc[xx + 1] >= 1:
				res -= 1
			if cc[xx - 1] >= 1:
				res -= 1
		print(res)
Main().solve()


import math
from decimal import Decimal

def na():
	n = int(input())
	b = [int(x) for x in input().split()]
	return (n, b)

def nab():
	n = int(input())
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	return (n, b, c)

def dv():
	(n, m) = list(map(int, input().split()))
	return (n, m)

def dva():
	(n, m) = list(map(int, input().split()))
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	return (n, m, b)

def eratosthenes(n):
	sieve = list(range(n + 1))
	for i in sieve:
		if i > 1:
			for j in range(i + i, len(sieve), i):
				sieve[j] = 0
	return sorted(set(sieve))

def nm():
	n = int(input())
	b = [int(x) for x in input().split()]
	m = int(input())
	c = [int(x) for x in input().split()]
	return (n, b, m, c)

def dvs():
	n = int(input())
	m = int(input())
	return (n, m)
(n, m) = list(map(int, input().split()))
aa = [int(x) for x in input().split()]
l = {i: m for i in range(n)}
r = {i: -1 for i in range(n)}
for (i, a) in enumerate(aa):
	l[a - 1] = min(i, l[a - 1])
	r[a - 1] = max(i, r[a - 1])
ans = 0
for i in range(n):
	for j in range(3):
		a = i
		b = i + j - 1
		if b < 0 or b == n:
			continue
		if l[a] > r[b]:
			ans += 1
print(ans)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
L = [1000000 for _ in range(n + 1)]
R = [-1 for _ in range(n + 1)]
for i in range(k):
	x = a[i]
	(L[x], R[x]) = (min(L[x], i), max(R[x], i))
total = 0
for x in range(1, n + 1):
	if R[x] == -1:
		total += 1
	if x - 1 > 0:
		if R[x] == -1 or R[x - 1] == -1 or R[x - 1] < L[x]:
			total += 1
	if x + 1 <= n:
		if R[x] == -1 or R[x + 1] == -1 or R[x + 1] < L[x]:
			total += 1
print(total)


from math import *
from collections import *
import sys
sys.setrecursionlimit(10 ** 9)
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
l = [k + 1 for i in range(n + 1)]
r = [-1 for i in range(n + 1)]
for i in range(k):
	if l[a[i]] == k + 1:
		l[a[i]] = i
	r[a[i]] = i
ct = 0
for i in range(1, n):
	if r[i] < l[i + 1]:
		ct += 1
for i in range(2, n + 1):
	if r[i] < l[i - 1]:
		ct += 1
ct += r.count(-1) - 1
print(ct)


import sys
(n, k) = list(map(int, input().split()))
x = list(map(int, input().split()))
s = 3 * n - 2
a = set()
for i in x:
	a.add((i, i))
	if (i - 1, i - 1) in a:
		a.add((i - 1, i))
	if (i + 1, i + 1) in a:
		a.add((i + 1, i))
print(s - len(a))


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
ceils = [0 for i in range(n)]
been = set()
ans = 3 * n - 2
for q in l:
	if ceils[q - 1] == 0:
		ans -= 1
	if q != 1:
		if ceils[q - 2] != 0 and (q - 1, q) not in been:
			ans -= 1
			been.add((q - 1, q))
	if q != n:
		if ceils[q] != 0 and (q + 1, q) not in been:
			ans -= 1
			been.add((q + 1, q))
	ceils[q - 1] += 1
print(max(ans, 0))


(n, k) = list(map(int, input().split()))
x = list(map(int, input().split()))
ml = []
for i in range(n):
	ml.append([])
for i in range(k):
	ml[x[i] - 1] += [i + 1]
c = 0
for i in range(n):
	if not ml[i]:
		c += 1
	if i != 0:
		if not ml[i] or not ml[i - 1] or min(ml[i]) > max(ml[i - 1]):
			c += 1
	if i != n - 1:
		if not ml[i] or not ml[i + 1] or min(ml[i]) > max(ml[i + 1]):
			c += 1
print(c)


def go():
	(n, m) = map(int, input().split(' '))
	s = set()
	a = [int(i) for i in input().split(' ')]
	for i in a:
		s.add((i, i))
		if i > 1:
			if (i - 1, i - 1) in s:
				s.add((i, i - 1))
		if i < n:
			if (i + 1, i + 1) in s:
				s.add((i, i + 1))
	return n * 3 - 2 - len(s)
print(go())


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
first_appear = {}
last_appear = {}
for i in range(k):
	last_appear[a[i]] = i
for i in range(k)[::-1]:
	first_appear[a[i]] = i
count = 0
for i in range(1, n + 1):
	for j in range(i - 1, i + 2):
		if 1 <= j <= n:
			if i not in first_appear:
				count += 1
			elif j not in last_appear:
				count += 1
			elif last_appear[j] < first_appear[i]:
				count += 1
print(count)


(n, k) = map(int, input().split())
X = list(map(int, input().split()))
fallen = set()
pairs = set()
for x in X:
	if x - 1 in fallen:
		pairs.add((x - 1) * (n + 1) + x)
	if x + 1 in fallen:
		pairs.add((x + 1) * (n + 1) + x)
	fallen.add(x)
print(2 * (n - 1) + n - len(pairs) - len(fallen))


import sys
(n, k) = map(int, input().split())
x = list(map(int, input().split()))
field_asked = [[-1, -1] for _ in range(n)]
for turn in range(k):
	if field_asked[x[turn] - 1][0] == -1:
		field_asked[x[turn] - 1][0] = turn + 1
	field_asked[x[turn] - 1][1] = turn + 1
scenarios = 0
for i in range(n):
	for j in range(max(0, i - 1), min(n, i + 2)):
		if field_asked[j][0] == -1 or field_asked[i][0] == -1 or field_asked[j][1] < field_asked[i][0]:
			scenarios += 1
print(scenarios)


(n, k) = [int(x) for x in input().split(' ')]
questions = [int(x) for x in input().split(' ')]
total = 3 * n - 2
visited_combo = {}
visited = [0] * (n + 1)
for i in range(k):
	q = questions[i]
	if not visited[q]:
		visited[q] = 1
		total -= 1
		visited_combo[q, q] = True
	if q > 1 and visited[q - 1] > 0 and (not visited_combo.get((q, q - 1), False)):
		total -= 1
		visited_combo[q, q - 1] = True
	if q < n and visited[q + 1] > 0 and (not visited_combo.get((q, q + 1), False)):
		total -= 1
		visited_combo[q, q + 1] = True
print(total)


(n, k) = list(map(int, input().split()))
li = list(map(int, input().split()))
l = [li[i] - 1 for i in range(k)]
ostatni = [-1] * n
pierwszy = [-1] * n
for i in range(k):
	if pierwszy[l[i]] == -1:
		pierwszy[l[i]] = i
	ostatni[l[i]] = i
wyn = 0
for i in range(n):
	if i > 0 and ostatni[i] < pierwszy[i - 1] and (ostatni[i] != -1) and (pierwszy[i - 1] != -1):
		wyn += 1
	if i < n - 1 and ostatni[i] < pierwszy[i + 1] and (ostatni[i] != -1) and (pierwszy[i + 1] != -1):
		wyn += 1
niema = 0
for i in range(0, n):
	if pierwszy[i] == -1:
		wyn += 5
for i in range(1, n):
	if pierwszy[i] == -1 and pierwszy[i - 1] == -1:
		wyn -= 2
if pierwszy[0] == -1:
	wyn -= 2
if pierwszy[n - 1] == -1:
	wyn -= 2
print(wyn)


def valid(l, r, x, y):
	return l[x] > r[y]
cin = lambda : [*map(int, input().split())]
(n, k) = cin()
x = cin()
l = [k + 1] * (n + 2)
r = [-1] * (n + 2)
vis = [0] * (n + 2)
for i in range(k - 1, -1, -1):
	l[x[i]] = i
for i in range(k):
	r[x[i]] = i
for i in x:
	vis[i] = 1
ans = n - sum(vis)
ans = ans + sum((valid(l, r, x, x + 1) for x in range(1, n + 1)))
ans = ans + sum((valid(l, r, x, x - 1) for x in range(1, n + 1)))
print(ans - 2)


from collections import Counter
(nums, num_questions) = map(int, input().split())
questions = list(map(int, input().split()))
exist = set()
things = dict(Counter(questions))
nums = nums * 3 - 2 - len(things)
for i in questions:
	if i not in exist:
		exist.add(i)
		if things.get(i - 1):
			nums -= 1
		if things.get(i + 1):
			nums -= 1
	things[i] -= 1
print(nums)


from collections import defaultdict
(n, k) = map(int, input().split())
List = [int(x) for x in input().split()]
From = [False] * n
To = [False] * n
Visited = defaultdict(bool)
Visited[List[-1]] = True
for i in range(k - 2, -1, -1):
	if Visited[List[i] - 1]:
		To[List[i] - 1] = True
	if Visited[List[i] + 1]:
		From[List[i]] = True
	Visited[List[i]] = True
Ans = 0
for i in range(1, n):
	if not From[i]:
		Ans += 1
	if not To[i]:
		Ans += 1
for i in range(1, n + 1):
	if not Visited[i]:
		Ans += 1
print(Ans)


from collections import defaultdict

def HideAndSeek(n, k, BobsQuestions):
	indices = defaultdict(list)
	for i in range(k):
		indices[BobsQuestions[i]].append(i)
	count = 0
	for i in range(1, n + 1):
		for j in range(max(i - 1, 1), min(i + 2, n + 1)):
			if i == j:
				if i not in indices:
					count += 1
			elif j not in indices or i not in indices:
				count += 1
			else:
				x = indices[i][0]
				y = indices[j][-1]
				if y < x:
					count += 1
	return count
(n, k) = map(int, input().split())
BobsQuestions = list(map(int, input().split()))
print(HideAndSeek(n, k, BobsQuestions))


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def solve():
	(n, k) = sep()
	x = lis()
	pos = [[] for i in range(n + 1)]
	for i in range(k):
		pos[x[i]].append(i + 1)
	for i in range(n + 1):
		pos[i] = sorted(pos[i])
	ans = 0
	for i in range(1, n + 1):
		if len(pos[i]) == 0:
			if i == 1 or i == n:
				ans += 2
			else:
				ans += 3
		else:
			if i < n:
				if len(pos[i + 1]) == 0 or pos[i][0] > pos[i + 1][len(pos[i + 1]) - 1]:
					ans += 1
			if i > 1:
				if len(pos[i - 1]) == 0 or pos[i][0] > pos[i - 1][len(pos[i - 1]) - 1]:
					ans += 1
	print(ans)
testcase(1)


(nCells, nQueries) = list(map(int, input().split()))
queries = list(map(int, input().split()))
seen = [False] * 100002
bad = set()
for q in queries:
	if not seen[q]:
		seen[q] = True
		bad.add((q, q))
	if seen[q - 1]:
		bad.add((q - 1, q))
	if seen[q + 1]:
		bad.add((q + 1, q))
print((nCells - 1) * 2 + nCells - len(bad))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = set()
res = (n - 2) * 2 + n + 2 - len(set(a))
used1 = set()
used2 = set()
for i in range(k - 1, -1, -1):
	if a[i] - 1 in b and a[i] not in used1:
		res -= 1
		used1.add(a[i])
	if a[i] + 1 in b and a[i] not in used2:
		res -= 1
		used2.add(a[i])
	b.add(a[i])
print(res)


from collections import defaultdict
(n, k) = map(int, input().split())
ar = [int(x) for x in input().split()]
first = [10000000000] * (n + 1)
last = [-1] * (n + 1)
for i in range(k):
	first[ar[i]] = min(first[ar[i]], i)
for i in range(k - 1, -1, -1):
	last[ar[i]] = max(last[ar[i]], i)
ans = 0
for i in range(1, n + 1):
	if last[i] == -1:
		ans += 1
	if i == n:
		continue
	if last[i] < first[i + 1]:
		ans += 1
	if last[i + 1] < first[i]:
		ans += 1
print(ans)


import sys
input = sys.stdin.readline
from collections import defaultdict

def lose(i, j):
	if i == j:
		return i in s
	else:
		return i in s and j in s and (first[i] < last[j])
(n, k) = map(int, input().split())
x = list(map(int, input().split()))
x = list(map(lambda x: x - 1, x))
s = set(x)
first = defaultdict(int)
last = defaultdict(int)
for i in range(k):
	if x[i] not in first:
		first[x[i]] = i
for i in range(k - 1, -1, -1):
	if x[i] not in last:
		last[x[i]] = i
ans = 3 * n - 2
for i in range(n):
	for j in range(max(i - 1, 0), min(i + 2, n)):
		if lose(i, j):
			ans -= 1
print(ans)


s = input().split()
n = int(s[0])
k = int(s[1])
s = input().split()
l = [int(x) for x in s]
f = [False for i in range(n + 1)]
for i in range(k):
	f[l[i]] = True
ans = 0
L = [0 for i in range(n + 1)]
R = [0 for i in range(n + 1)]
for i in range(k):
	R[l[i]] = i
for i in range(k - 1, -1, -1):
	L[l[i]] = i
for i in range(1, n + 1):
	ans += not f[i]
for i in range(1, n):
	if not f[i] or not f[i + 1]:
		ans += 2
		continue
	if L[i] > R[i + 1]:
		ans += 1
	if L[i + 1] > R[i]:
		ans += 1
print(ans)


def getn():
	return int(input())

def getns():
	return [int(x) for x in input().split()]
(n, k) = getns()
ks = getns()
f = [None] * (n + 1)
l = [None] * (n + 1)
ans = 3 * n - 2
for i in range(k):
	c = ks[i]
	if f[c] == None:
		f[c] = i
		ans -= 1
	l[c] = i
for i in range(1, n):
	if f[i] != None and l[i + 1] != None and (f[i] < l[i + 1]):
		ans -= 1
for i in range(2, n + 1):
	if f[i] != None and l[i - 1] != None and (f[i] < l[i - 1]):
		ans -= 1
print(ans)


(n, k) = [int(i) for i in input().split(' ')]
l = [[-1, -1] for i in range(n)]
x = [int(i) - 1 for i in input().split(' ')]
total = n * 3 - 2
for (i, v) in enumerate(x):
	if l[v] == [-1, -1]:
		total -= 1
		l[v][:] = [i, i]
	elif i < l[v][0]:
		l[v][0] = i
	elif i > l[v][1]:
		l[v][1] = i
for (i, v) in enumerate(l):
	if i == 0:
		continue
	if 0 <= v[0] < l[i - 1][1]:
		total -= 1
	if 0 <= l[i - 1][0] < v[1]:
		total -= 1
print(total)


(n, k) = map(int, input().split())
res = 2 * (n - 1) + n
l = list(map(int, input().split()))
lup = [0] * (n + 1)
for i in range(k):
	lup[l[i]] += 1
	if lup[l[i]] == 1:
		res -= 1
lol = [1] * (n + 1)
lol[0] = 0
for i in range(len(l)):
	lup[l[i]] -= 1
	if lol[l[i]] == 1:
		lol[l[i]] = 0
		if l[i] + 1 <= n:
			if lup[l[i] + 1] >= 1:
				res -= 1
		if l[i] - 1 >= 1:
			if lup[l[i] - 1] >= 1:
				res -= 1
if res < 0:
	res = 0
print(res)


import sys
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
(n, k) = Ri()
a = Ri()
ans = 0
s = set()
dicinc = {}
dicdec = {}
for i in range(k - 1, -1, -1):
	if a[i] + 1 <= n:
		if a[i] + 1 not in s:
			dicinc[a[i]] = True
		else:
			dicinc[a[i]] = False
	if a[i] - 1 >= 1:
		if a[i] - 1 not in s:
			dicdec[a[i]] = True
		else:
			dicdec[a[i]] = False
	s.add(a[i])
for i in dicinc:
	if dicinc[i] >= 0:
		ans += dicinc[i]
for i in dicdec:
	if dicdec[i] >= 0:
		ans += dicdec[i]
rem = n - len(s)
if 1 not in s:
	ans -= 1
if n not in s:
	ans -= 1
ans += rem * 3
print(ans)


from math import *
from collections import *
from bisect import *
import sys
input = sys.stdin.readline
t = 1
while t:
	t -= 1
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	vis = set()
	for i in a:
		vis.add((i, i))
		if (i - 1, i - 1) in vis:
			vis.add((i - 1, i))
		if (i + 1, i + 1) in vis:
			vis.add((i + 1, i))
	r = n + 2 * n - 2
	print(r - len(vis))


(n, k) = map(int, input().split())
ques = []
last = [-1] * (n + 2)
last[0] = 10000000
last[n + 1] = 10000000
frst = [-1] * (n + 2)
ques = input().split()
for i in range(len(ques)):
	ques[i] = int(ques[i])
ans = n * 3
for i in range(k):
	if frst[ques[i]] == -1:
		frst[ques[i]] = i
	last[ques[i]] = i
cnt = 0
for i in range(1, n + 1):
	if frst[i] != -1:
		if frst[i] < last[i - 1]:
			cnt += 1
		if frst[i] < last[i + 1]:
			cnt += 1
		if frst[i] != -1:
			cnt += 1
if frst[1] == -1:
	cnt += 1
if frst[n] == -1:
	cnt += 1
ans = ans - cnt
print(ans)


(n, k) = list(map(int, input().strip().split()))
x = list(map(int, input().strip().split()))
guess = {i: [0] for i in range(1, n + 1)}
for (i, e) in enumerate(x):
	guess[e].append(i + 1)
cnt = 0
for i in range(1, n + 1):
	if len(guess[i]) == 1:
		cnt += 1
		if i > 1:
			cnt += 1
		if i < n:
			cnt += 1
	elif len(guess[i]) > 1:
		move = guess[i][1]
		if i > 1:
			if move > guess[i - 1][-1]:
				cnt += 1
		if i < n:
			if move > guess[i + 1][-1]:
				cnt += 1
print(cnt)


(n, k) = [int(t) for t in input().split(' ')]
queries = [int(t) - 1 for t in input().split(' ')]
asked = [0] * n
impos = set()
for q in queries:
	impos.add((q, q))
	for offset in [-1, 1]:
		loc = q + offset
		if loc >= n or loc < 0:
			continue
		if asked[loc]:
			impos.add((loc, q))
	asked[q] += 1
possible = n * 3 - 2
print(possible - len(impos))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
first = {}
last = {}
for i in range(k):
	last[a[i]] = i
	if a[i] not in first:
		first[a[i]] = i
for p in range(1, n + 1):
	if p not in first:
		ans += 1
	if p != n and first.get(p, float('inf')) > last.get(p + 1, float('-inf')):
		ans += 1
	if p != 1 and first.get(p, float('inf')) > last.get(p - 1, float('-inf')):
		ans += 1
print(ans)


(n, k) = [int(x) for x in input().split()]
maxG = [0] * n
minG = [10 ** 5 + 1] * n
L = [int(x) - 1 for x in input().split()]
for (i, x) in enumerate(L):
	minG[x] = min(minG[x], i + 1)
	maxG[x] = max(maxG[x], i + 1)
res = 0
for i in range(n - 1):
	res += minG[i] >= maxG[i + 1]
for i in range(1, n):
	res += minG[i] >= maxG[i - 1]
for i in range(n):
	res += maxG[i] == 0
print(res)


(n, k) = map(int, input().split())
d = dict()
i = 0
count = 0
questions = []
for el in map(int, input().split()):
	questions.append(el)
	if el in d:
		d[el][1] = i
	else:
		d[el] = [i, i]
	i += 1
s = set(questions)
for i in range(1, n):
	if i not in s or i + 1 not in s or d[i][0] > d[i + 1][1]:
		count += 1
for i in range(2, n + 1):
	if i not in s or i - 1 not in s or d[i][0] > d[i - 1][1]:
		count += 1
for i in range(1, n + 1):
	if i not in s:
		count += 1
print(count)


import sys
(n, k) = map(int, input().split())
lis = list(map(int, input().split()))
v = [0] * (n + 2)
p = [0] * (n + 2)
c = [0] * n
for i in lis:
	i -= 1
	c[i] = 1
	if i + 1 < n and c[i + 1] == 1:
		v[i + 1] = 1
	if i - 1 >= 0 and c[i - 1] == 1:
		p[i - 1] = 1
x = 0
for i in lis:
	i -= 1
	if c[i]:
		x += c[i] + v[i] + p[i]
	else:
		if i + 1 < n:
			x += c[i + 1]
		if i - 1 >= 0:
			x += c[i - 1]
x = 0
for i in range(0, n):
	x += c[i] + v[i + 1] + p[i - 1]
print(3 * n - 2 - x)


def main():
	(n, k) = map(int, input().split())
	x = [int(i) for i in input().split()]
	ans = 3 * n - 2
	(a, b) = (set(), set())
	for val in x:
		if val - 1 in a:
			b.add((val, val - 1))
		if val + 1 in a:
			b.add((val, val + 1))
		a.add(val)
	ans -= len(a) + len(b)
	print(max(ans, 0))
main()


(n, k) = [int(x) for x in input().split()]
q = [int(x) for x in input().split()]
f = 0
incl = set()
counted = {}
for i in range(k - 1, -1, -1):
	if q[i] + 1 in incl and str(q[i]) + '+1' not in counted:
		f += 1
		counted[str(q[i]) + '+1'] = True
	if q[i] - 1 in incl and str(q[i]) + '-1' not in counted:
		f += 1
		counted[str(q[i]) + '-1'] = True
	incl.add(q[i])
print(3 * n - 2 - f - len(incl))


def main():
	from sys import stdin, stdout

	def read():
		return stdin.readline().rstrip('\n')

	def read_array(sep=None, maxsplit=-1):
		return read().split(sep, maxsplit)

	def read_int():
		return int(read())

	def read_int_array(sep=None, maxsplit=-1):
		return [int(a) for a in read_array(sep, maxsplit)]

	def write(*args, **kwargs):
		sep = kwargs.get('sep', ' ')
		end = kwargs.get('end', '\n')
		stdout.write(sep.join((str(a) for a in args)) + end)

	def write_array(array, **kwargs):
		sep = kwargs.get('sep', ' ')
		end = kwargs.get('end', '\n')
		stdout.write(sep.join((str(a) for a in array)) + end)
	(n, m) = read_int_array()
	guesses = read_int_array()
	tried = set()
	banned = set()
	for x in guesses:
		tried.add(x)
		banned.add((x, x))
		if x - 1 in tried:
			banned.add((x - 1, x))
		if x + 1 in tried:
			banned.add((x + 1, x))
	write(n * 3 - 2 - len(banned))
main()


(n, k) = map(int, input().split())
array = list(map(int, input().split()))
d = {i: 0 for i in range(1, n + 1)}
dind = {}
ind = 0
for e in array:
	d[e] += 1
	dind[e] = ind
	ind += 1
sum = 0
prooved = set()
for (i, x) in enumerate(array):
	if x > 1:
		if (x, x - 1) not in prooved:
			if d[x - 1] == 0:
				sum += 1
			elif dind[x - 1] < i:
				sum += 1
			prooved.add((x, x - 1))
	if x < n:
		if (x, x + 1) not in prooved:
			if d[x + 1] == 0 and (x, x + 1):
				sum += 1
			elif dind[x + 1] < i:
				sum += 1
		prooved.add((x, x + 1))
for i in range(1, n + 1):
	if d[i] == 0:
		sum += 1
		if i != 1:
			sum += 1
		if i != n:
			sum += 1
print(sum)


(n, k) = list(map(int, input().split()))
ar = list(map(lambda x: int(x) - 1, input().split()))
fidx = [k] * n
lidx = [-1] * n
for (i, e) in enumerate(ar):
	lidx[e] = i
	fidx[e] = min(fidx[e], i)
out = 0
for v in range(n):
	if fidx[v] == k:
		out += 3 if v not in (0, n - 1) else 2
	else:
		if v != 0 and lidx[v - 1] < fidx[v]:
			out += 1
		if v != n - 1 and lidx[v + 1] < fidx[v]:
			out += 1
print(out)


(N, K) = map(int, input().split())
X = list(map(lambda x: int(x) - 1, input().split()))
inf = 10 ** 9 + 7
Fi = [inf] * N
La = [-1] * N
for (i, x) in enumerate(X):
	Fi[x] = min(Fi[x], i)
for (i, x) in enumerate(X[::-1]):
	La[x] = max(La[x], K - 1 - i)
ans = sum((1 if l < 0 else 0 for l in La))
for i in range(N - 1):
	if Fi[i] > La[i + 1]:
		ans += 1
	if Fi[i + 1] > La[i]:
		ans += 1
print(ans)


import math
import bisect
import heapq
from collections import defaultdict

def egcd(a, b):
	if a == 0:
		return (b, 0, 1)
	else:
		(g, x, y) = egcd(b % a, a)
		return (g, y - b // a * x, x)

def mulinv(b, n):
	(g, x, _) = egcd(b, n)
	if g == 1:
		return x % n
primes = []

def isprime(n):
	for d in range(2, int(math.sqrt(n)) + 1):
		if n % d == 0:
			return False
	return True

def argsort(ls):
	return sorted(range(len(ls)), key=ls.__getitem__)

def f(p=0):
	if p == 1:
		return map(int, input().split())
	elif p == 2:
		return list(map(int, input().split()))
	else:
		return int(input())
(n, k) = f(1)
cl = f(2)
if n == 1:
	print(0)
else:
	dl = [-1] * (n + 2)
	for i in range(k):
		if dl[cl[i]] == -1:
			dl[cl[i]] = i
	pl = [[0 for _ in range(3)] for _ in range(n + 2)]
	for i in range(k - 1, -1, -1):
		if i >= dl[cl[i] - 1]:
			pl[cl[i] - 1][2] = 1
		if i >= dl[cl[i] + 1]:
			pl[cl[i] + 1][0] = 1
		pl[cl[i]][1] = 1
	res = 4 + (n - 2) * 3
	for i in range(1, n + 1):
		if dl[i] != -1:
			res -= sum(pl[i])
	print(res)


import sys
(n, k) = map(int, input().split())
q = list(map(int, input().split()))
if n == 1:
	print(0)
	sys.exit()
res = max(n - 2, 0) * 3 + 4
arr = [0] * n
l_flags = [False] * n
r_flags = [False] * n
for i in q:
	i -= 1
	if arr[i] == 0:
		res -= 1
	arr[i] += 1
	if i > 0 and arr[i - 1] > 0 and (not l_flags[i]):
		res -= 1
		l_flags[i] = True
	if i < n - 1 and arr[i + 1] > 0 and (not r_flags[i]):
		res -= 1
		r_flags[i] = True
print(res)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
d = dict()

def countGreater(arr, n, k):
	l = 0
	r = n - 1
	leftGreater = n
	while l <= r:
		m = int(l + (r - l) / 2)
		if arr[m] > k:
			leftGreater = m
			r = m - 1
		else:
			l = m + 1
	return n - leftGreater

def check(i, j):
	if len(d[i]) == 0:
		return True
	ind = d[i][0]
	n = len(d[j])
	if countGreater(d[j], n, ind) != 0:
		return False
	return True
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
for i in range(m):
	if l[i] not in d:
		d.update({l[i]: [i]})
	else:
		d[l[i]].append(i)
ans = 0
for i in range(1, n + 1):
	if i not in d:
		d.update({i: []})
for i in range(1, n + 1):
	if i != n:
		if check(i, i + 1):
			ans += 1
	if i != 1:
		if check(i, i - 1):
			ans += 1
	if len(d[i]) == 0:
		ans += 1
print(ans)


import sys

def get_array():
	return list(map(int, sys.stdin.readline().split()))

def get_ints():
	return map(int, sys.stdin.readline().split())

def input():
	return sys.stdin.readline().strip()

def main():
	(n, k) = get_ints()
	d = {}
	arr = [0] * (n + 1)
	flag = [False] * (n + 1)
	inp = get_array()
	ans = 0
	for i in range(k):
		p = inp[i]
		arr[p] += 1
		d[p] = 1
	for i in range(k):
		p = inp[i]
		if flag[p] == True:
			arr[p] = max(0, arr[p] - 1)
			continue
		ans -= 1
		if p > 1:
			if arr[p - 1] != 0:
				ans -= 1
		if p < n:
			if arr[p + 1] != 0:
				ans -= 1
		arr[p] = max(arr[p] - 1, 0)
		flag[p] = True
	ans += 3 * (n - 2) + 4
	if ans < 0:
		ans = 0
	print(ans)
main()


exec('import sys\nn, k = [int(i) for i in input().split()]\nif n == 1:\n    print(0)\n    sys.exit()\n\n\nfind = [100001] * (n+1)\nlind = [0] * (n+1)\nq = [int(i) for i in input().split()]\nfor i in range(k):\n    find[q[i]] = min(i+1, find[q[i]])\n    lind[q[i]] = max(i+1, lind[q[i]])\n\ns = 0\nif lind[1] == 0:\n    s += 1\nif find[1] > lind[2]:\n    s += 1\nif lind[n] == 0:\n    s += 1\nif find[n] > lind[n-1]:\n    s += 1\nfor i in range(2, n):\n    if find[i] > lind[i+1]:\n        s += 1\n    if find[i] > lind[i-1]:\n        s += 1\n    if lind[i] == 0:\n        s += 1\n\n\n\nprint(s)')


(n, k) = map(int, input().split())
qu = list(map(int, input().split()))
a = [-1] * (n + 1)
b = [-1] * (n + 1)
for i in range(k):
	x = qu[i]
	if a[x] == -1:
		a[x] = i
		b[x] = i
	else:
		b[x] = i
an = 0
if n == 1:
	if a[1] == -1:
		an = 1
else:
	if a[1] == -1:
		an += 2
	elif b[2] < a[1]:
		an += 1
	if a[n] == -1:
		an += 2
	elif b[n - 1] < a[n]:
		an += 1
	for i in range(2, n):
		if a[i] == -1:
			an += 3
		else:
			if b[i - 1] < a[i]:
				an += 1
			if b[i + 1] < a[i]:
				an += 1
print(an)


(n, k) = map(int, input().split())
xs = list(map(int, input().split()))
st = {}
pairs = set()
for x in xs:
	if x in st.keys():
		st[x] += 1
	else:
		st[x] = 1
	pairs.add((x, x))
for x in xs:
	if x + 1 in st.keys() and st[x + 1] > 0:
		pairs.add((x, x + 1))
	if x - 1 in st.keys() and st[x - 1] > 0:
		pairs.add((x, x - 1))
	st[x] -= 1
print(2 * (n - 1) + n - len(pairs))


from collections import Counter, defaultdict
(N, K) = map(int, input().split())
x_ls = list(map(int, input().split()))
c = Counter(x_ls)
ans = 0
count_notin = 0
for i in range(1, N + 1):
	if c[i] == 0:
		count_notin += 1
		ans += 1
		if i > 1:
			ans += 1
		if i < N:
			ans += 1
checked = defaultdict(int)
for (j, x) in enumerate(x_ls):
	if checked[x]:
		c[x] -= 1
		continue
	if x > 1:
		if c[x - 1] == 0:
			ans += 1
	if x < N:
		if c[x + 1] == 0:
			ans += 1
	c[x] -= 1
	checked[x] = 1
print(ans)


from collections import defaultdict
(n, k) = map(int, input().split())
lis = list(map(int, input().split()))
first = {}
last = defaultdict(int)
length = len(lis)
for i in range(length):
	if lis[i] not in first:
		first[lis[i]] = i
	last[lis[i]] = i
count = 0
for i in range(1, n + 1):
	if i not in first:
		if i == 1 or i == n:
			count += 2
		else:
			count += 3
		continue
	if i - 1 > 0 and first[i] >= last[i - 1]:
		count += 1
	if i + 1 <= n and first[i] >= last[i + 1]:
		count += 1
print(count)


def main():
	(n, k) = map(int, input().split())
	x = list(map(int, input().split()))
	minus1 = [False] * (k + 1)
	plus1 = [False] * (k + 1)
	dminus1 = {}
	dplus1 = {}
	for (i, val) in enumerate(x):
		if val < n and val + 1 in dminus1:
			for ind in dminus1[val + 1]:
				minus1[ind] = True
			del dminus1[val + 1]
		if val > 1 and val - 1 in dplus1:
			for ind in dplus1[val - 1]:
				plus1[ind] = True
			del dplus1[val - 1]
		if val in dminus1:
			dminus1[val].append(i)
		else:
			dminus1[val] = [i]
		if val in dplus1:
			dplus1[val].append(i)
		else:
			dplus1[val] = [i]
	usedMinus1 = set()
	usedPlus1 = set()
	res = n - len(set(x)) + (n - 2) * 2 + 2
	for (i, val) in enumerate(x):
		if val != n and plus1[i] and (val not in usedPlus1):
			res -= 1
			usedPlus1.add(val)
		if val != 1 and minus1[i] and (val not in usedMinus1):
			res -= 1
			usedMinus1.add(val)
	print(res)
main()


(n, k) = map(int, input().split())
q = list(map(int, input().split()))
seen = [False] * (n + 2)
cnt = (n - 2) * 3 + 2 * 2
impossible = set()
for x in q:
	seen[x] = True
	impossible.add((x, x))
	if seen[x - 1]:
		impossible.add((x, x - 1))
	if seen[x + 1]:
		impossible.add((x, x + 1))
print(cnt - len(impossible))


n_k = input().split()
n = int(n_k[0])
k = int(n_k[1])
q_dict = {}
qs = input().split()
for i in range(k):
	q = int(qs[i]) - 1
	if q in q_dict:
		q_dict[q][1] = i
	else:
		q_dict[q] = [i, i]
case = 0
for i in range(n):
	if i not in q_dict:
		case += 1
	s = [i - 1, i + 1]
	for end in s:
		if end >= 0 and end < n:
			if i in q_dict and end in q_dict:
				if q_dict[end][1] < q_dict[i][0]:
					case += 1
			elif end not in q_dict and i in q_dict:
				if q_dict[i][1] < k:
					case += 1
			else:
				case += 1
print(case)


from collections import defaultdict
(n, k) = [int(item) for item in input().split()]
x = [int(item) for item in input().split()]
occ = defaultdict(list)
for i in range(k):
	occ[x[i]].append(i)
ans = 0
for i in range(1, n + 1):
	old = ans
	if not i in occ:
		if i == 1 or i == n:
			ans += 2
		else:
			ans += 3
		continue
	if i < n and (i + 1 not in occ or occ[i][0] > occ[i + 1][-1]):
		ans += 1
	if i > 1 and (i - 1 not in occ or occ[i][0] > occ[i - 1][-1]):
		ans += 1
print(ans)


(n, k) = map(int, input().split())
x = list(map(int, input().split()))
d = {}
for i in range(k):
	d[x[i]] = i
ans = 0
v = [0] * n
for i in range(k):
	if v[x[i] - 1] == 0:
		if x[i] != 1:
			if d.get(x[i] - 1) == None or d.get(x[i] - 1) < i:
				ans += 1
		if x[i] != n:
			if d.get(x[i] + 1) == None or d.get(x[i] + 1) < i:
				ans += 1
		v[x[i] - 1] = 1
ans += 3 * (n - len(d))
if d.get(1) == None:
	ans -= 1
if d.get(n) == None:
	ans -= 1
print(ans)


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
dict1 = {}
for i in range(1, n + 1):
	dict1[i] = []
for i in range(k):
	dict1[arr[i]].append(i)
ans = 0
for i in range(1, n + 1):
	if i == 1:
		if n == 1:
			break
		if len(dict1[1]) == 0:
			ans += 2
		elif len(dict1[2]) == 0:
			ans += 1
		elif dict1[2][-1] < dict1[1][0]:
			ans += 1
	elif i == n:
		if len(dict1[n]) == 0:
			ans += 2
		elif len(dict1[n - 1]) == 0:
			ans += 1
		elif dict1[n - 1][-1] < dict1[n][0]:
			ans += 1
	elif len(dict1[i]) == 0:
		ans += 3
	else:
		if len(dict1[i - 1]) == 0:
			ans += 1
		elif dict1[i - 1][-1] < dict1[i][0]:
			ans += 1
		if len(dict1[i + 1]) == 0:
			ans += 1
		elif dict1[i + 1][-1] < dict1[i][0]:
			ans += 1
print(ans)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
count = (n - 1) * 2 + n
b = [[0, -1] for i in range(n + 2)]
c = set()
for i in range(len(a)):
	if b[a[i] - 1][0] != 0 and b[a[i]][0] == 0:
		count -= 1
	if b[a[i] + 1][0] != 0 and b[a[i]][0] == 0:
		count -= 1
	if b[a[i]][0] == 0:
		count -= 1
	l1 = (a[i] + 1, a[i])
	l2 = (a[i], a[i] + 1)
	if b[a[i] + 1][1] > b[a[i]][1] and b[a[i] + 1][0] != 0 and (b[a[i]][0] != 0) and (l1 not in c) and (l2 not in c):
		count -= 1
		c.add(l1)
		c.add(l2)
	l3 = (a[i], a[i] - 1)
	l4 = (a[i] - 1, a[i])
	if b[a[i] - 1][1] > b[a[i]][1] and b[a[i] - 1][0] != 0 and (b[a[i]][0] != 0) and (l3 not in c) and (l4 not in c):
		count -= 1
		c.add(l3)
		c.add(l4)
	b[a[i]][0] = 1
	b[a[i]][1] = i
print(count)


(n, k) = map(int, input().split())
x = list(map(int, input().split()))
First = [k] * (n + 1)
Last = [-1] * (n + 1)
for i in range(k):
	if First[x[i]] == k:
		First[x[i]] = i
	Last[x[i]] = i
result = 0
for i in range(1, n + 1, 1):
	for j in range(i - 1, i + 2, 1):
		if j > 0 and j <= n:
			if First[i] > Last[j]:
				result += 1
print(result)


(n, k) = [int(x) for x in input().split()]
x = [int(x) for x in input().split()]
counter = {}
answer = 0
for i in range(1, n + 1):
	counter[i, i - 1] = 0
	counter[i, i] = 0
	counter[i, i + 1] = 0
stop = set()
for item in x:
	stop.add(item)
	if item - 1 in stop:
		counter[item - 1, item] = 1
	if item in stop:
		counter[item, item] = 1
	if item + 1 in stop:
		counter[item + 1, item] = 1
for item in counter:
	if counter[item] == 0:
		answer += 1
print(answer - 2)


(n, k) = map(int, input().split())
x = [int(i) for i in input().split()]
first = [int(k + 1) for _ in range(n + 1)]
last = [int(-1) for _ in range(n + 1)]
for i in range(k):
	first[x[i]] = min(first[x[i]], i)
	last[x[i]] = max(last[x[i]], i)
cnt = 0
for i in range(1, n + 1):
	if last[i] == -1:
		cnt += 1
	if i + 1 <= n:
		if last[i] < first[i + 1]:
			cnt += 1
		if last[i + 1] < first[i]:
			cnt += 1
print(cnt)


(n, k) = map(int, input().split())
q = list(map(int, input().split()))
seen = set()
possible_scen = set()
possible_scen.add((1, 1))
if n > 1:
	possible_scen.add((1, 2))
for item in range(2, n):
	possible_scen.add((item, item - 1))
	possible_scen.add((item, item))
	possible_scen.add((item, item + 1))
if n > 1:
	possible_scen.add((n, n - 1))
possible_scen.add((n, n))
for item in q:
	if (item, item) in possible_scen:
		possible_scen.remove((item, item))
	if item + 1 in seen:
		if (item + 1, item) in possible_scen:
			possible_scen.remove((item + 1, item))
	if item - 1 in seen:
		if (item - 1, item) in possible_scen:
			possible_scen.remove((item - 1, item))
	seen.add(item)
print(len(possible_scen))


(n, k) = map(int, input().split())
A = list(map(int, input().split()))
tot = 2 * (n - 1) + n
s = set()
for i in A:
	s.add((i, i))
	if (i - 1, i - 1) in s:
		s.add((i - 1, i))
	if (i + 1, i + 1) in s:
		s.add((i + 1, i))
print(tot - len(s))