Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is h_{i}. Liss wants to eat all nuts.

Now Liss is on the root of the tree with the number 1. In one second Liss can perform one of the following actions:  Walk up or down one unit on a tree.  Eat a nut on the top of the current tree.  Jump to the next tree. In this action the height of Liss doesn't change. More formally, when Liss is at height h of the tree i (1 ≤ i ≤ n - 1), she jumps to height h of the tree i + 1. This action can't be performed if h > h_{i} + 1. 

Compute the minimal time (in seconds) required to eat all nuts.


-----Input-----

The first line contains an integer n (1  ≤  n ≤ 10^5) — the number of trees.

Next n lines contains the height of trees: i-th line contains an integer h_{i} (1 ≤ h_{i} ≤ 10^4) — the height of the tree with the number i.


-----Output-----

Print a single integer — the minimal time required to eat all nuts in seconds.


-----Examples-----
Input
2
1
2

Output
5

Input
5
2
1
2
1
1

Output
14

Source: codeforces | Difficulty: EASY
Tags: Implementation

Greedy algorithms


Solutions:
n = int(input())
l = []
for _ in range(n):
	l.append(int(input()))
t = len(l)
current = 0
t += l[0] - current
current = l[0]
for i in range(1, n):
	if current <= l[i]:
		t += 1 + l[i] - current
		current = l[i]
	else:
		t += 1 + current - l[i]
		current = l[i]
print(t)


n = int(input())
r = n * 2 - 1
h = 0
for i in range(n):
	t = int(input())
	r += abs(h - t)
	h = t
print(r)


n = int(input())
h = []
for i in range(n):
	h.append(int(input()))
count = h[0] + 1
prev = h[0]
for i in range(1, len(h)):
	if h[i] > prev:
		count += h[i] - prev + 2
		prev = h[i]
	elif h[i] < prev:
		count += prev - h[i] + 2
		prev = h[i]
	elif h[i] == prev:
		count += 2
print(count)


n = int(input())
L = []
for i in range(n):
	k = int(input())
	L.append(k)
time = L[0] + 1
for i in range(n - 1):
	time += 1
	if L[i] <= L[i + 1]:
		time += L[i + 1] - L[i] + 1
	else:
		time += L[i] - L[i + 1] + 1
print(time)


n = int(input())
m = n * 2 - 1
h = 0
for i in range(n):
	a = int(input())
	m += abs(h - a)
	h = a
print(m)


N = int(input())
lh = 0
Stp = int(-1)
for wi in range(1, N + 1):
	h = int(input())
	Stp += abs(h - lh) + 2
	lh = h
print(Stp)


n = int(input())
l = []
for i in range(n):
	l.append(int(input()))
res = l[0] + 1
for i in range(1, n):
	if l[i] < l[i - 1]:
		res += l[i - 1] - l[i] + 2
	elif l[i] == l[i - 1]:
		res += 2
	else:
		res += l[i] - l[i - 1] + 2
print(res)


from collections import deque
from math import log, sqrt, ceil

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def li():
	return list(mi())
n = ii()
a = []
for i in range(n):
	a.append(ii())
s = a[0] + 1
for i in range(1, n):
	if a[i] >= a[i - 1]:
		s += a[i] - a[i - 1] + 1 + 1
	else:
		s += a[i - 1] - a[i] + 1 + 1
print(s)


n = int(input())
ans = []
for i in range(n):
	h = int(input())
	ans.append(h)
t = 0
height = 0
i = 0
while i < n:
	t += ans[i] - height + 1
	if i + 1 < n:
		if ans[i + 1] >= ans[i]:
			t += 1
			height = ans[i]
			i += 1
		else:
			t += ans[i] - ans[i + 1] + 1
			height = ans[i + 1]
			i += 1
	else:
		break
print(t)


n = int(input())
count = 0
g = int(input())
count += g + 1
for i in range(n - 1):
	a = int(input())
	if a > g:
		count += a - g + 1 + 1
		g = a
	else:
		count += g - a + 1 + 1
		g = a
print(count)


n = int(input())
t = []
for i in range(0, n):
	t.append(int(input()))
time = n + n - 1
for i in range(0, n):
	if i == 0:
		time += t[0]
	else:
		time += abs(t[i] - t[i - 1])
print(time)


s = 0
pos = 0
n = int(input())
for i in range(n):
	h = int(input())
	if i < n - 1:
		if pos == 0:
			s += h + 2
			pos = h
		elif pos > h:
			s += pos - h + 2
			pos = h
		elif pos < h:
			s += h - pos + 2
			pos = h
		else:
			s += 2
			pos = h
	elif pos > h:
		s += pos - h + 1
		pos = h
	elif pos < h:
		s += h - pos + 1
		pos = h
	else:
		s += 1
		pos = h
print(s)


n = int(input())
m = int(input())
s = n + m + n - 1
for i in range(n - 1):
	c = int(input())
	s += abs(m - c)
	m = c
print(s)


n = int(input())
a = []
for i in range(0, n):
	a.append(int(input()))
ans = 0
ans += a[0]
ans += 1
for i in range(0, n - 1):
	if a[i] <= a[i + 1]:
		ans += 1
		ans += a[i + 1] - a[i]
		ans += 1
	else:
		ans += a[i] - a[i + 1]
		ans += 1
		ans += 1
print(ans)


temp = 0
(c, jump, eat) = (0, 1, 1)
for i in range(int(input())):
	n = int(input())
	if i == 0:
		c += n + eat
		temp = n
	else:
		if temp > n:
			c += temp - n
			c += jump
			c += eat
		else:
			c += jump
			c += n - temp + eat
		temp = n
print(c)


a = int(input())
b = []
for k in range(a):
	z = int(input())
	b.append(z)
suma = b[0] + 1
for s in range(1, a):
	if b[s] > b[s - 1]:
		suma = suma + 1 + (b[s] - b[s - 1]) + 1
	if b[s] < b[s - 1]:
		suma = suma + (b[s - 1] - b[s]) + 1 + 1
	if b[s] == b[s - 1]:
		suma = suma + 2
print(suma)


num = int(input())
(h, res) = (0, -1)
for x in range(num):
	i = int(input())
	res += abs(i - h) + 2
	h = i
print(res)


(l, c) = ([], -1)
for i in range(int(input())):
	l.append(int(input()))
	if len(l) == 1:
		c += l[i]
	else:
		c += abs(l[i] - l[i - 1])
print(c + len(l) * 2)


n = int(input())
l = []
for i in range(n):
	h = int(input())
	l.append(h)
s = 0
for i in range(n):
	if i == 0:
		s += l[i] + 1
	elif l[i] == l[i - 1]:
		s += 2
	elif l[i] < l[i - 1]:
		s += 1 + (l[i - 1] - l[i]) + 1
	elif l[i] > l[i - 1]:
		s += 1 + (l[i] - l[i - 1]) + 1
print(s)


n = int(input())
a = [int(input()) for i in range(n)]
time = a[0] + n
for i in range(1, n):
	time += 1 + a[i - 1] - a[i] if a[i] <= a[i - 1] else 1 + a[i] - a[i - 1]
print(time)


xx = 0
c = 0
for i in range(int(input())):
	a = int(input())
	c += abs(a - xx) + 2
	xx = a
print(c - 1)


n = int(input())
hii = int(input())
count = hii
for i in range(1, n):
	hi = int(input())
	count += abs(hii - hi) + 1
	hii = hi
print(count + n)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
import random
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

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

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def main():
	n = I()
	a = [I() for _ in range(n)]
	r = n - 1
	c = 0
	for t in a:
		r += abs(c - t) + 1
		c = t
	return r
print(main())


n = int(input())
z = 0
count = 0
for i in range(n):
	x = int(input())
	if x == z:
		count += 2
	elif x > z:
		count += abs(x - z)
		count += 2
	else:
		count += abs(x - z)
		count += 2
	z = x
print(count - 1)


import sys
input = sys.stdin.buffer.readline
n = int(input())
h = []
for i in range(n):
	h.append(int(input()))
time = 1 + h[0]
for i in range(1, n):
	time += 2
	if h[i] >= h[i - 1]:
		time += h[i] - h[i - 1]
	else:
		time += h[i - 1] - h[i]
print(time)


n = int(input())
t = 0
for i in range(n):
	h = int(input())
	if i == 0:
		t += h
	else:
		t += abs(h - cache) + 1
	cache = h
print(t + n)


n = int(input())
curh = 0
total = 0
for i in range(n):
	a = int(input())
	if curh == 0:
		total += a + 1
		curh = a
	elif curh <= a:
		total += a - curh + 1 + 1
		curh = a
	else:
		total += curh - a + 2
		curh = a
print(total)


height = []
for _ in range(int(input())):
	height.append(int(input()))
ans = 1 + height[0]
for i in range(1, len(height)):
	if height[i] >= height[i - 1]:
		ans += 1 + height[i] - height[i - 1] + 1
	else:
		ans += 2 + height[i - 1] - height[i]
print(ans)


h = 0
sec = 0
for i in range(int(input())):
	n = int(input())
	if i == 0:
		h = n
		sec = n + 1
		continue
	if n == h:
		sec += 2
	else:
		sec += abs(n - h) + 2
	h = n
print(sec)


x = int(input())
t = 0
h = 0
array = []
for i in range(x):
	p = int(input())
	array.append(p)
for i in range(x):
	u = array[i] - h
	t = t + u
	h = h + u
	t = t + 1
	if i + 1 != x:
		if h > array[i + 1]:
			h = h - (array[i] - array[i + 1])
			t = t + (array[i] - array[i + 1])
		t = t + 1
print(t)


def program():
	a = []
	t = 0
	n = int(input())
	for i in range(n):
		a.append(int(input()))
	t = a[0] + 1
	for j in range(1, len(a)):
		t += abs(a[j] - a[j - 1]) + 2
	print(t)
program()


n = int(input())
l = [int(input()) for _ in range(n)]
ans = n + l[0]
for i in range(1, n):
	ans += abs(l[i - 1] - l[i]) + 1
print(ans)


n = int(input())
l = []
s = 0
curh = 0
for i in range(n):
	a = int(input())
	l.append(a)
for i in l:
	s += abs(i - curh) + 2
	curh = i
print(s - 1)


n = int(input())
r = 0
a = 1
for i in range(n):
	b = int(input())
	r += abs(a - b) + 2
	a = b
print(r)


n = int(input())
t = 0
x = 0
for i in range(n):
	a = int(input())
	if i == 0:
		t += a
	else:
		t += abs(a - x) + 1
	x = a
print(t + n)


n = int(input())
h = []
for i in range(n):
	h.append(int(input()))
height = h[0]
sum = 0
for i in range(n):
	sum += height + 1
	if i == n - 1:
		continue
	height = abs(h[i + 1] - h[i])
	sum += 1
print(sum)


n = int(input())
a = []
ans = 0
h = 0
for i in range(n):
	x = int(input())
	if h < x:
		ans += x - h
	else:
		ans += h - x
	ans += 1
	h = x
ans += n - 1
print(ans)


n = int(input())
L = []
for i in range(n):
	L.append(int(input()))
c = L[0]
for i in range(1, n):
	if L[i] != L[i - 1]:
		c += abs(L[i] - L[i - 1])
c = c + 2 * n - 1
print(c)


n = int(input())
l = []
for i in range(n):
	l.append(int(input()))
c = n * 2 - 1 + l[0]
for i in range(1, n):
	c += abs(l[i] - l[i - 1])
print(c)


n = int(input())
h = [int(input()) for i in range(n)]
t = h[0] + 1
for i in range(1, n):
	if h[i] >= h[i - 1]:
		t += h[i] - h[i - 1] + 2
	elif h[i] < h[i - 1]:
		t += h[i - 1] - h[i] + 2
print(t)


from sys import stdin
max_val = int(10000000000000.0)
min_val = int(-10000000000000.0)

def read_int():
	return int(stdin.readline())

def read_ints():
	return [int(x) for x in stdin.readline().split()]

def read_str():
	return input()

def read_strs():
	return [x for x in stdin.readline().split()]
nb_tree = read_int()
last = 0
need = -1
for _ in range(nb_tree):
	height = int(input())
	need += abs(height - last) + 2
	last = height
print(need)


n = int(input())
l = [int(input()) for i in range(n)]
sm = 0
sm += n
sm += n - 1
pr = 0
i = 0
while i < n:
	curr = l[i]
	c = 0
	while i < n and curr == l[i]:
		i += 1
		c += 1
	sm += abs(pr - curr)
	pr = curr
print(sm)


n = int(input())
l = []
time = 0
for i in range(n):
	a = int(input())
	l.append(a)
for i in range(n):
	if time == 0:
		time = time + l[i] + 1
	elif l[i] < l[i - 1]:
		time = time + l[i - 1] - l[i] + 1 + 1
	else:
		time = time + 1 + l[i] - l[i - 1] + 1
print(time)


n = int(input())
acthight = int(input())
cont = acthight + 1
for i in range(n - 1):
	t = int(input())
	cont += abs(acthight - t) + 2
	acthight = t
print(cont)


n = int(input())
heights = []
for x in range(n):
	h = int(input())
	heights.append(h)
a = heights[0]
for x in range(n - 1):
	a += abs(heights[x + 1] - heights[x]) + 2
a += 1
print(a)


ans = 0
prev_pos = 0
for i in range(int(input())):
	curr_pos = int(input())
	ans = ans + abs(curr_pos - prev_pos) + 2
	prev_pos = curr_pos
ans = ans - 1
print(ans)


from sys import stdin, stdout
n = int(stdin.readline())
w = []
for i in range(n):
	w.append(int(stdin.readline()))
cost = 2 * n - 1 + w[0]
for k in range(1, n):
	cost += abs(w[k] - w[k - 1])
stdout.write(str(cost))


def foo():
	n = int(input())
	h = [int(input()) for i in range(0, n)]
	curX = 0
	res = 0
	for x in h:
		if x < curX:
			res += curX - x
			curX = x
		res += x - curX
		curX = x
		res += 2
	print(res - 1)
foo()


from sys import stdin
stdin.readline

def mp():
	return list(map(int, stdin.readline().strip().split()))

def it():
	return int(stdin.readline().strip())
v = []
n = it()
for _ in range(n):
	v += [it()]
ans = v[0] + 1
for i in range(1, n):
	if v[i] >= v[i - 1]:
		ans += v[i] - v[i - 1] + 2
	else:
		ans += v[i - 1] - v[i] + 2
print(ans)


n = int(input())
prev_ht = int(input())
seconds = 2 * n - 1 + prev_ht
for i in range(n - 1):
	num = int(input())
	if num >= prev_ht:
		seconds += num - prev_ht
		prev_ht = num
	else:
		seconds += prev_ht - num
		prev_ht = num
print(seconds)


n = int(input())
count = 0
h = int(input())
count = h + 1
while n > 1:
	n -= 1
	h1 = int(input())
	if h > h1:
		count += h - h1
		h = h1
	count += 1
	count += h1 - h
	count += 1
	h = h1
print(count)


n = int(input())
h = []
for _ in range(n):
	h += [int(input())]
pos = 0
i = 0
ans = 0
while i < n - 1:
	ans += h[i] - pos + 1
	pos = h[i]
	if h[i + 1] < pos:
		ans += pos - h[i + 1] + 1
		pos = h[i + 1]
	else:
		ans += 1
	i += 1
ans += h[n - 1] - pos + 1
print(ans)


n = int(input())
curr = 0
time = 0
prev = 0
for i in range(n):
	h = int(input())
	if prev <= h:
		curr = prev
	else:
		time += prev - h
		curr = h
	time += h - curr + 1
	prev = h
print(time + (n - 1))


n = int(input())
a = []
ans = n + n - 1
for i in range(n):
	a.append(int(input()))
ans += a[0]
for i in range(1, n):
	ans += abs(a[i] - a[i - 1])
print(ans)


import sys
N = int(sys.stdin.readline())
H = []
for i in range(N):
	h = int(sys.stdin.readline())
	H.append(h)
ans = H[0] + 1
p = H[0]
for i in range(1, N):
	if H[i] >= p:
		ans += 1 + (H[i] - p) + 1
		p = H[i]
	else:
		ans += p - H[i] + 1 + 1
		p = H[i]
print(ans)


N = int(input())
hts = [0]
for i in range(N):
	hts.append(int(input()))
jmp_time = N - 1
eat_time = N
move_time = 0
for i in range(N):
	move_time += abs(hts[i] - hts[i + 1])
tot_time = jmp_time + eat_time + move_time
print(tot_time)


n = int(input())
b = []
for i in range(n):
	a = int(input())
	b.append(a)
s = b[0]
for i in range(n - 1):
	if b[i] >= b[i + 1]:
		s = s + b[i] - b[i + 1]
	else:
		s = s + b[i + 1] - b[i]
print(s + n + n - 1)


n = int(input())
height = []
for _ in range(n):
	height.append(int(input()))
time = height[0] + 1
lasth = height[0]
for i in range(1, n):
	time += 2 + abs(height[i] - lasth)
	lasth = height[i]
print(time)


n = int(input())
H = [int(input()) for _ in range(n)]
print(2 * n - 1 + sum((abs(h1 - h2) for (h1, h2) in zip([0] + H, H))))


import math

def ii():
	return int(input())

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

def li():
	return list(mi())
n = ii()
a = []
for i in range(n):
	a.append(ii())
res = a[0]
for i in range(1, n):
	res += abs(a[i] - a[i - 1])
print(res + n + (n - 1))


n = int(input())
a = []
for i in range(n):
	h = int(input())
	a.append(h)
cur_h = 0
cur_h = a[0]
second = a[0] + 1
for i in range(1, n):
	if a[i] >= cur_h:
		second += a[i] - cur_h + 1
		second += 1
		cur_h = a[i]
	else:
		second += cur_h - a[i]
		second += 1
		second += 1
		cur_h = a[i]
print(second)


n = int(input())
first = int(input())
total = first
prev = first
for x in range(n - 1):
	now = int(input())
	if now >= prev:
		total += 1 + now - prev
	else:
		total += 1 + prev - now
	prev = now
print(total + n)


i = 0
ans = 0
past = 0
for x in range(int(input())):
	n = int(input())
	if i == 0:
		ans = n + 1
		past = n
	else:
		ans += abs(past - n) + 2
	i += 1
	past = n
print(ans)


n = int(input())
l = []
for i in range(n):
	j = int(input())
	l += [j]
c = l[0] + 1
for i in range(1, n):
	if i == 1:
		if l[0] == l[1]:
			c += 2
		elif l[0] > l[1]:
			c += l[0] - l[1] + 2
		elif l[0] < l[1]:
			c += l[1] - l[0] + 2
	elif l[i - 1] == l[i]:
		c += 2
	elif l[i - 1] > l[i]:
		c += l[i - 1] - l[i] + 2
	elif l[i - 1] < l[i]:
		c += l[i] - l[i - 1] + 2
print(c)


import sys
n = int(sys.stdin.readline())
actHigh = 0
seconds = 0
aux = int(sys.stdin.readline())
seconds += aux + 1
actHigh = aux
for i in range(1, n):
	aux = int(sys.stdin.readline())
	if actHigh > aux:
		seconds += actHigh - aux + 2
	else:
		seconds += aux - actHigh + 2
	actHigh = aux
print(seconds)


import os.path
from math import gcd, floor, ceil
from collections import *
import sys
mod = 1000000007
INF = float('inf')

def st():
	return list(sys.stdin.readline().strip())

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

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

def inp():
	return int(sys.stdin.readline())

def pr(n):
	return sys.stdout.write(str(n) + '\n')

def prl(n):
	return sys.stdout.write(str(n) + ' ')
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def solve():
	n = inp()
	l = [inp() for i in range(n)]
	cur = l[0]
	ans = l[0] + 1
	for i in range(1, n):
		if l[i] < cur:
			ans += cur - l[i]
			cur = l[i]
		ans += l[i] - cur + 1
		cur = l[i]
	ans += n - 1
	pr(ans)
for _ in range(1):
	solve()


n = int(input())
a = 1
s = 0
for _ in range(n):
	h = int(input())
	s = s + abs(a - h) + 2
	a = h
print(s)


t = input()
n = int(t)
treeList = []
time = 0
for i in range(n):
	s = input()
	temp = int(s)
	treeList.append(temp)
time = treeList[0] + 1
for i in range(1, n):
	if treeList[i - 1] > treeList[i]:
		time = time + (treeList[i - 1] - treeList[i]) + 1 + 1
	else:
		time = time + 1 + (treeList[i] - treeList[i - 1]) + 1
print(time)


n = int(input())
l = []
s = 0
for i in range(n):
	l.append(int(input()))
	if i == 0:
		s += l[i] + 1
	else:
		s += abs(l[i] - l[i - 1]) + 2
print(s)


n = int(input())
sum = 0
a = []
for i in range(n):
	a.append(int(input()))
	if i == 0:
		sum += a[i] + 1
	else:
		sum += abs(a[i] - a[i - 1]) + 2
print(sum)


amount = input()
amount = int(amount)
count = amount + amount - 1
h = 0
for i in range(0, amount):
	h0 = int(input())
	count += abs(h - h0)
	h = h0
print(count)


from sys import stdin
t = int(stdin.readline())
ans = 0
a = 1
for k in range(t):
	b = int(stdin.readline())
	ans += abs(a - b) + 2
	a = b
print(ans)


n = int(input())
h = 0
res = 0
for i in range(n):
	s = int(input())
	res += abs(s - h) + 1
	if i != 0:
		res += 1
	h = s
print(res)


n = int(input())
cur = int(input())
time = cur
for i in range(n - 1):
	nex = int(input())
	if cur > nex:
		time += cur - nex
	else:
		time += nex - cur
	time += 2
	cur = nex
print(time + 1)


n = int(input())
s1 = []
for i in range(n):
	n1 = int(input())
	s1.append(n1)
s = s1[0] + n
for j in range(n - 1):
	s += abs(s1[j] - s1[j + 1]) + 1
print(s)


import sys
import math
n = int(sys.stdin.readline())
c = 0
res = 0
for i in range(n):
	v = int(sys.stdin.readline())
	res += int(math.fabs(c - v))
	c = v
print(res + n + (n - 1))


cases = int(input())
tot = 0
c = []
for i in range(cases):
	c.append(int(input()))
for i in range(len(c)):
	if i == 0:
		tot += c[i] + 1
	else:
		tot += abs(c[i] - c[i - 1]) + 2
print(tot)


n = int(input())
h = int(input())
t = h + 1
for _ in range(n - 1):
	i = int(input())
	t += abs(i - h) + 2
	h = i
print(t)


ans = 0
curheight = 0
n = int(input())
for i in range(n):
	x = int(input())
	if i > 0:
		ans += 1
	if x > curheight:
		ans += 1 + x - curheight
	else:
		ans += 1 + curheight - x
	curheight = x
print(ans)


n = int(input())
d = n
e = n - 1
a = []
for i in range(n):
	n = int(input())
	a.append(n)
sum = a[0]
for i in range(0, len(a) - 1):
	sum = sum + abs(a[i] - a[i + 1])
print(sum + d + e)


from __future__ import division, print_function
from collections import *
from math import *
from itertools import *
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def main():
	n = int(input())
	arr = []
	for q in range(n):
		arr.append(int(input()))
	moves = arr[0] + 1
	for p in range(1, n):
		moves += abs(arr[p] - arr[p - 1]) + 2
	print(moves)
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))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


n = int(input())
(x, y) = (0, 0)
for i in range(n):
	h = int(input())
	x += abs(y - h) + 2
	y = h
print(x - 1)


n = int(input())
(ans, h) = (2 * n - 1, 0)
for i in range(n):
	j = int(input())
	ans += abs(h - j)
	h = j
print(ans)


def tree_hopping(a, n):
	time = a[0] + 1
	for x in range(1, n):
		time += abs(a[x] - a[x - 1]) + 2
	return time
n = int(input())
a = []
for x in range(n):
	a.append(int(input()))
print(tree_hopping(a, n))


from __future__ import division, print_function
import math
import os
import sys
from fractions import *
from sys import *
from io import BytesIO, IOBase
from itertools import *
from collections import *
M = 10 ** 9 + 7
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
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))
input = lambda : sys.stdin.readline().rstrip('\r\n')

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 fsep():
	return map(float, inp().split())

def inpu():
	return int(inp())

def regularbracket(t):
	p = 0
	for i in t:
		if i == '(':
			p += 1
		else:
			p -= 1
		if p < 0:
			return False
	else:
		if p > 0:
			return False
		else:
			return True

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] <= key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def reverse1(string):
	pp = ''
	for i in string[::-1]:
		pp += i
	if pp == string:
		return True
	return False

def reverse2(list1):
	l = []
	for i in list1[::-1]:
		l.append(i)
	if l == list1:
		return True
	return False

def mex(list1):
	p = max(list1) + 1
	for i in range(len(list1)):
		if list1[i] != i:
			p = i
			break
	return p

def sumofdigits(n):
	n = str(n)
	s1 = 0
	for i in n:
		s1 += int(i)
	return s1

def perfect_square(n):
	s = math.sqrt(n)
	if s == int(s):
		return True
	return False

def roman_number(x):
	if x > 15999:
		return
	value = [5000, 4000, 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
	symbol = ['F', 'MF', 'M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I']
	roman = ''
	i = 0
	while x > 0:
		div = x // value[i]
		x = x % value[i]
		while div:
			roman += symbol[i]
			div -= 1
		i += 1
	return roman

def soretd(s):
	for i in range(1, len(s)):
		if s[i - 1] > s[i]:
			return False
	return True

def countRhombi(h, w):
	ct = 0
	for i in range(2, h + 1, 2):
		for j in range(2, w + 1, 2):
			ct += (h - i + 1) * (w - j + 1)
	return ct

def countrhombi2(h, w):
	return h * h // 4 * (w * w // 4)

def binpow(a, b):
	if b == 0:
		return 1
	else:
		res = binpow(a, b // 2)
	if b % 2 != 0:
		return res * res * a
	else:
		return res * res

def binpowmodulus(a, b, m):
	a %= m
	res = 1
	while b > 0:
		if b & 1:
			res = res * a % m
		a = a * a % m
		b >>= 1
	return res

def coprime_to_n(n):
	result = n
	i = 2
	while i * i <= n:
		if n % i == 0:
			while n % i == 0:
				n //= i
			result -= result // i
		i += 1
	if n > 1:
		result -= result // n
	return result

def prime(x):
	if x == 1:
		return False
	else:
		for i in range(2, int(math.sqrt(x)) + 1):
			if x % i == 0:
				return False
		else:
			return True

def luckynumwithequalnumberoffourandseven(x, n, a):
	if x >= n and str(x).count('4') == str(x).count('7'):
		a.append(x)
	elif x < 1000000000000.0:
		luckynumwithequalnumberoffourandseven(x * 10 + 4, n, a)
		luckynumwithequalnumberoffourandseven(x * 10 + 7, n, a)
	return a

def luckynuber(x, n, a):
	p = set(str(x))
	if len(p) <= 2:
		a.append(x)
	if x < n:
		luckynuber(x + 1, n, a)
	return a

def interact(type, x):
	if type == 'r':
		inp = input()
		return inp.strip()
	else:
		print(x, flush=True)

def findTrailingZeros(n):
	count = 0
	while n >= 5:
		n //= 5
		count += n
	return count

def mergeSort(arr):
	if len(arr) > 1:
		mid = len(arr) // 2
		L = arr[:mid]
		R = arr[mid:]
		mergeSort(L)
		mergeSort(R)
		i = j = k = 0
		while i < len(L) and j < len(R):
			if L[i] < R[j]:
				arr[k] = L[i]
				i += 1
			else:
				arr[k] = R[j]
				j += 1
			k += 1
		while i < len(L):
			arr[k] = L[i]
			i += 1
			k += 1
		while j < len(R):
			arr[k] = R[j]
			j += 1
			k += 1
res = set()

def solven(p, l, a, b, n):
	if p > n or l > 10:
		return
	if p > 0:
		res.add(p)
	solven(p * 10 + a, l + 1, a, b, n)
	solven(p * 10 + b, l + 1, a, b, n)

def subsetsUtil(A, subset, index, d):
	print(*subset)
	s = sum(subset)
	d.append(s)
	for i in range(index, len(A)):
		subset.append(A[i])
		subsetsUtil(A, subset, i + 1, d)
		subset.pop(-1)
	return d

def subsetSums(arr, l, r, d, sum=0):
	if l > r:
		d.append(sum)
		return
	subsetSums(arr, l + 1, r, d, sum + arr[l])
	subsetSums(arr, l + 1, r, d, sum)
	return d

def print_factors(x):
	factors = []
	for i in range(1, x + 1):
		if x % i == 0:
			factors.append(i)
	return factors

def calc(X, d, ans, D):
	if len(X) == 0:
		return
	i = X.index(max(X))
	ans[D[max(X)]] = d
	Y = X[:i]
	Z = X[i + 1:]
	calc(Y, d + 1, ans, D)
	calc(Z, d + 1, ans, D)

def good(b):
	l = []
	i = 0
	while len(b) != 0:
		if b[i] < b[len(b) - 1 - i]:
			l.append(b[i])
			b.remove(b[i])
		else:
			l.append(b[len(b) - 1 - i])
			b.remove(b[len(b) - 1 - i])
	if l == sorted(l):
		return True
	return False

def generate(st, s):
	if len(s) == 0:
		return
	if s not in st:
		st.add(s)
		for i in range(len(s)):
			t = list(s).copy()
			t.remove(s[i])
			t = ''.join(t)
			generate(st, t)
	return

def main():
	r = 0
	a = 1
	for _ in range(inpu()):
		b = int(inpu())
		r += abs(a - b) + 2
		a = b
	print(r)
main()


n = int(input())
l = []
for i in range(n):
	l.append(int(input()))
l.insert(0, 0)
su = 0
for i in range(1, len(l)):
	su += abs(l[i] - l[i - 1])
su += n + n - 1
print(su)


from sys import stdin, stdout
from collections import Counter

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

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

def ip():
	return int(stdin.readline().strip())

def op(ans):
	return stdout.write(str(ans) + '\n')
from math import ceil
n = ip()
s = n
li = []
for i in range(n):
	li.append(ip())
for i in range(n):
	if i == 0:
		s += li[i]
	elif li[i] < li[i - 1]:
		s += li[i - 1] - li[i] + 1
	elif li[i] > li[i - 1]:
		s += 1 + li[i] - li[i - 1]
	else:
		s += 1
op(s)


n = int(input())
a = []
for i in range(n):
	a += [int(input())]
print(2 * n - 1 + a[0] + sum((abs(a[i] - a[i - 1]) for i in range(1, n))))


n = int(input())
b = []
count = 0
for i in range(n):
	c = int(input())
	b.append(c)
count += b[0] + 1
for i in range(1, len(b)):
	if b[i] > b[i - 1]:
		count += b[i] - b[i - 1] + 2
	elif b[i] == b[i - 1]:
		count += 2
	else:
		count += b[i - 1] - b[i] + 2
print(count)


n = int(input())
steps = 0
tmp = int(input())
steps += tmp + 1
for i in range(n - 1):
	x = int(input())
	if tmp > x:
		steps += tmp - x + 2
		tmp = x
	elif tmp <= x:
		steps += x - tmp + 2
		tmp = x
print(steps)


t = int(input())
h = []
for _ in range(t):
	x = int(input())
	h.append(x)
c = h[0]
for i in range(len(h) - 1):
	d = abs(h[i] - h[i + 1])
	c += d + 1
c += t
print(c)


n = int(input())
currPos = 0
ans = 0
for i in range(n):
	h = int(input())
	ans += abs(currPos - h) + 1
	currPos = h
	ans += 1
print(ans - 1)


n = int(input())
a = []
for i in range(n):
	a.append(int(input()))
t = a[0] + 1
for i in range(1, n):
	t += abs(a[i] - a[i - 1]) + 2
print(t)


from math import fabs
while 1:
	try:
		n = int(input())
		a = []
		for i in range(0, n):
			a.append(int(input()))
		summ = a[0] + 1
		for i in range(1, n):
			summ += fabs(a[i - 1] - a[i]) + 2
		print(int(summ))
	except EOFError:
		break


import sys

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

def iinput():
	return int(input())

def tinput():
	return input().split()

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())
n = iinput()
A = [-1] * n
for i in range(n):
	A[i] = iinput()
cost = A[0] + 1
for i in range(1, n):
	cost += 1
	if A[i] >= A[i - 1]:
		cost += A[i] - A[i - 1] + 1
	else:
		cost += A[i - 1] - A[i] + 1
print(cost)


n = int(input())
count = 0
t = int(input())
count = t + 1
l = [t]
for i in range(n - 1):
	z = int(input())
	if z < l[-1]:
		count += l[-1] - z + 1 + 1
		l.append(z)
	else:
		count += 1 + z - l[-1] + 1
		l.append(z)
print(count)


t = int(input())
l = []
while t:
	t = t - 1
	l.append(int(input()))
n = len(l)
c = n + n - 1 + l[0]
for i in range(0, n - 1):
	c += abs(l[i] - l[i + 1])
print(c)


import os
import sys
from io import BytesIO, IOBase
import math

def main():
	pass
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()
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
n = int(input())
curr = 0
t = 0
for i in range(n):
	if i != 0:
		t += 1
	k = int(input())
	if k == curr:
		t += 1
	if k < curr:
		t += curr - k + 1
	if k > curr:
		t += k - curr + 1
	curr = k
print(t)


t = int(input())
h = 0
time = 2 * t - 1
n = [int(input()) for i in range(t)]
for j in range(t):
	time += 2 * n[j]
	if j > 0:
		time -= n[j] + n[j - 1] - abs(n[j] - n[j - 1])
print(time - n[t - 1])


x = int(input())
h = [0] * x
for i in range(x):
	h[i] = int(input())
s = h[0] + 1
for i in range(1, x):
	s += 2 + abs(h[i] - h[i - 1])
print(s)


from math import *
n = int(input())
l = [0] * (n + 1)
for i in range(0, n):
	l[i] = int(input())
t = l[0] + 1
for i in range(1, n):
	t += abs(l[i] - l[i - 1]) + 2
print(t)


trees = int(input())
stuffs = 0
pre = 0
for x in range(trees):
	thing = int(input())
	stuffs += 1
	stuffs += abs(thing - pre)
	pre = thing
	if x != trees - 1:
		stuffs += 1
print(stuffs)


import sys, math
sys.setrecursionlimit(2000)
input = sys.stdin.readline

def inp():
	return int(input())

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
n = inp()
h = [0]
for i in range(n):
	x = inp()
	h.append(x)
dp = [0]
dp.append(h[1] + 1)
for i in range(2, n + 1):
	dp.append(abs(h[i - 1] - h[i]) + dp[i - 1] + 2)
print(dp[n])


import sys
import time
import os
from math import sqrt, log, log2, ceil, log10, gcd, floor, pow, sin, cos, tan, pi, inf, factorial
from copy import copy, deepcopy
from sys import exit, stdin, stdout
from collections import Counter, defaultdict, deque
from itertools import permutations
import heapq
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
mod = 1000000007
iinp = lambda : int(sys.stdin.readline())
inp = lambda : sys.stdin.readline().strip()
strl = lambda : list(inp().strip().split(' '))
intl = lambda : list(map(int, inp().split(' ')))
mint = lambda : map(int, inp().split())
flol = lambda : list(map(float, inp().split(' ')))
flush = lambda : stdout.flush()

def permute(nums):

	def fun(arr, nums, cur, v):
		if len(cur) == len(nums):
			arr.append(cur.copy())
		i = 0
		while i < len(nums):
			if v[i]:
				i += 1
				continue
			else:
				cur.append(nums[i])
				v[i] = 1
				fun(arr, nums, cur, v)
				cur.pop()
				v[i] = 0
				i += 1
		return arr
	res = []
	nums.sort()
	v = [0] * len(nums)
	return fun(res, nums, [], v)

def subsets(res, index, arr, cur):
	res.append(cur.copy())
	for i in range(index, len(arr)):
		cur.append(arr[i])
		subsets(res, i + 1, arr, cur)
		cur.pop()
	return res

def sieve(N):
	root = int(sqrt(N))
	primes = [1] * (N + 1)
	(primes[0], primes[1]) = (0, 0)
	for i in range(2, root + 1):
		if primes[i]:
			for j in range(i * i, N + 1, i):
				primes[j] = 0
	return primes

def bs(arr, l, r, x):
	if x < arr[0] or x > arr[len(arr) - 1]:
		return -1
	while l <= r:
		mid = l + (r - l) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] < x:
			l = mid + 1
		else:
			r = mid - 1
	return -1

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	p = int(sqrt(n))
	for i in range(5, p + 1, 6):
		if n % i == 0 or n % (i + 2) == 0:
			return False
	return True

def fun(arr, mid, l):
	n = len(arr)
	if mid < arr[0] or mid < l - arr[-1]:
		return False
	for i in range(n - 1):
		if not arr[i] + mid >= arr[i + 1] - mid:
			return False
	return True

def solve():
	n = iinp()
	arr = []
	prev = 0
	ans = 0
	for i in range(n):
		arr.append(iinp())
	ans = n + n - 1 + arr[0]
	for i in range(1, n):
		if arr[i] < arr[i - 1]:
			ans += arr[i - 1] - arr[i]
		else:
			ans += arr[i] - arr[i - 1]
	print(ans)
start_time = time.time()
solve()


import sys
input = sys.stdin.readline

def inp():
	return int(input())

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
n = inp()
arr = []
for i in range(0, n):
	x = inp()
	arr.append(x)
ans = 0
ans += arr[0] + 1
for i in range(0, n - 1):
	ans += 2 + abs(arr[i] - arr[i + 1])
print(ans)


import sys
import math
import bisect

def solve(A):
	n = len(A)
	ans = n
	for i in range(n):
		if i == 0:
			ans += A[i]
		else:
			ans += abs(A[i] - A[i - 1]) + 1
	return ans

def main():
	A = []
	for _ in range(int(input())):
		A.append(int(input()))
	print(solve(A))
main()


n = int(input())
lst = list()
for i in range(n):
	s = int(input())
	lst.append(s)
(result, temp) = (2 * n - 1 + lst[0], 0)
for i in range(1, n):
	temp = lst[i] - lst[i - 1]
	result += abs(temp)
print(result)


f = lambda : map(int, input().split())
n = int(input())
a = int(input())
t = a + 1
for i in range(n - 1):
	b = int(input())
	if b > a:
		t += b - a + 2
	elif b < a:
		t += a - b + 2
	else:
		t += 2
	a = b
print(t)


n = int(input())
a = []
for i in range(n):
	ele = int(input())
	a.append(ele)
total = 0
jump = 1
eat = 1
total = total + a[0] + eat
for i in range(1, n):
	total = total + abs(a[i] - a[i - 1]) + jump + eat
print(total)


n = int(input())
arr = []
for i in range(n):
	a = int(input())
	arr.append(a)
su = n + (n - 1) + arr[0]
for i in range(0, n - 1):
	if arr[i + 1] > arr[i]:
		su += arr[i + 1] - arr[i]
	elif arr[i + 1] < arr[i]:
		su += arr[i] - arr[i + 1]
print(su)


n = int(input())
h = [int(input()) for i in range(n)]
moves = h[0] + 1
prev = h[0]
for i in range(1, n):
	moves += 2 + abs(h[i] - h[i - 1])
	prev = h[i]
print(moves)


a = int(input())
L = []
for i in range(a):
	L.append(int(input()))
sum = L[0] + 1
for i in range(len(L) - 1):
	sum += 2 + abs(L[i + 1] - L[i])
print(sum)


a = int(input())
l = []
ans = 0
for i in range(a):
	l.append(int(input()))
ans += l[0] + 1
for i in range(len(l) - 1):
	ans += l[i] - min(l[i], l[i + 1]) + (l[i + 1] - min(l[i], l[i + 1])) + 2
print(ans)


n = int(input())
h = []
for _ in range(n):
	h.append(int(input()))
ans = h[0] + 1
for i in range(1, n):
	if h[i] >= h[i - 1]:
		ans += h[i] - h[i - 1] + 1
	else:
		ans += h[i - 1] - h[i] + 1
print(ans + n - 1)


n = int(input())
ans = 0
cur = 0
for i in range(n):
	h = int(input())
	if i == 0:
		ans += h + 1
		cur = h
	else:
		if cur >= h:
			ans += cur - h + 2
		elif cur < h:
			ans += h - cur + 2
		cur = h
print(ans)


n = int(input())
list1 = []
for i in range(n):
	list1.append(int(input()))
s = list1[0] + 1
for i in range(1, n):
	if list1[i] < list1[i - 1]:
		s += list1[i - 1] - list1[i] + 1
		s += 1
	else:
		s += 1
		s += list1[i] - list1[i - 1] + 1
print(s)


n = int(input())
l = []
for x in range(n):
	l.append(int(input()))
ans = l[0] + 1
for x in range(1, n):
	ans += abs(l[x] - l[x - 1]) + 2
print(ans)


h_prev = 0
time = 0
for _ in range(int(input())):
	h = int(input())
	if h < h_prev:
		time += h_prev - h + 1
	elif h > h_prev:
		time += h - h_prev + 1
	else:
		time += 1
	if h_prev != 0:
		time += 1
	h_prev = h
print(time)


n = int(input())
t = []
for j in range(n):
	l = int(input())
	t.append(l)
count = 0
for i in range(n - 1):
	m = abs(t[i] - t[i + 1])
	count = count + m
print(count + n + t[0] + n - 1)


n = int(input())
ans = int(input()) + 1
a = ans - 1
for i in range(n - 1):
	x = int(input())
	ans += abs(a - x) + 2
	a = x
print(ans)


n = int(input())
arr = [0] * n
for i in range(0, n):
	x = int(input())
	arr[i] = x
ans = 0
ans += arr[0] + 1
for i in range(0, n - 1):
	ans += 2 + abs(arr[i] - arr[i + 1])
print(ans)


n = int(input())
a = []
for i in range(0, n):
	x = int(input())
	a.append(x)
sum = 0
h = 0
for i in range(0, n):
	sum += abs(h - a[i])
	h = a[i]
	sum = sum + 2
print(sum - 1)


n = int(input())
p = t = 0
for l in [int(input()) for i in range(n)]:
	p += abs(t - l)
	t = l
print(p + 2 * n - 1)


n = int(input())
hash = {}
l = [int(input()) for i in range(n)]
for i in range(n):
	hash[i] = False
time = l[0] + 1
hash[0] = True
for i in range(n - 1):
	if l[i] <= l[i + 1] and hash[i] == True:
		time += l[i + 1] - l[i] + 2
		hash[i + 1] = True
	elif l[i] > l[i + 1] and hash[i] == True:
		time += l[i] - l[i + 1] + 2
		hash[i + 1] = True
	elif l[i] <= l[i + 1] and hash[i] == False:
		time += l[i] + 1 + l[i + 1] - l[i] + 2
		hash[i] = True
		hash[i + 1] = True
	elif l[i] > l[i + 1] and hash[i] == False:
		time += l[i] + 1 + l[i] - l[i + 1] + 2
		hash[i] = True
		hash[i + 1] = True
print(time)


from sys import stdin
inp = lambda : stdin.readline().strip()
n = int(inp())
a = []
for i in range(n):
	a.append(int(inp()))
ans = a[0] + 1
for i in range(1, n):
	ans += abs(a[i] - a[i - 1]) + 2
print(ans)


def main():
	n = int(input())
	a = []
	for i in range(n):
		a.append(int(input()))
	if n == 1:
		return a[0] + 1
	h = 0
	ans = 0
	for i in range(n):
		if a[i] == h:
			pass
		elif a[i] < h:
			return -1
		else:
			ans += a[i] - h
			h = a[i]
		ans += 1
		if i < n - 1:
			if a[i + 1] < h:
				dif = h - a[i + 1]
				ans += dif
				h -= dif
			ans += 1
	return ans
print(main())


s = []
for i in range(int(input())):
	s.append(int(input()))
c = 0
for i in range(len(s) - 1):
	c += abs(s[i + 1] - s[i])
print(c + s[0] + len(s) - 1 + len(s))


n = int(input())
table = []
ans = 0
for i in range(n):
	table.append(int(input()))
for i in range(n):
	if i == 0:
		ans += table[0]
		place = table[0]
	elif place > table[i]:
		ans += abs(table[i] - place)
		place = table[i]
	else:
		ans += abs(table[i] - place)
		place = table[i]
print(ans + 2 * n - 1)


import os
import sys
from io import BytesIO, IOBase
import math as M
import itertools as ITR
from collections import defaultdict as D
from collections import Counter as C
from collections import deque as Q
import threading
from functools import lru_cache, reduce
from functools import cmp_to_key as CMP
from bisect import bisect_left as BL
from bisect import bisect_right as BR
import random as R
import string
import cmath, time
enum = enumerate
start_time = time.time()
MOD = 1000000007
MA = float('inf')
MI = float('-inf')
di8 = [(1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)]
di4 = [(1, 0), (0, 1), (-1, 0), (0, -1)]

def increase_stack():
	sys.setrecursionlimit(2 ** 32 // 2 - 1)
	threading.stack_size(1 << 27)
	t = threading.Thread(target=main)
	t.start()
	t.join()

def prints(a):
	print(a, end=' ')

def binary(n):
	return bin(n)[2:]

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def maxfactor(n):
	q = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			q.append(i)
	if q:
		return q[-1]

def factors(n):
	q = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			q.append(i)
			q.append(n // i)
	return list(sorted(list(set(q))))

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(M.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(i)
			n = n / i
	if n > 2:
		l.append(int(n))
	l.sort()
	return l

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def seive(n):
	a = [1]
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p ** 2, n + 1, p):
				prime[i] = False
		p = p + 1
	for p in range(2, n + 1):
		if prime[p]:
			a.append(p)
	return a

def maxPrimeFactors(n):
	maxPrime = -1
	while n % 2 == 0:
		maxPrime = 2
		n >>= 1
	for i in range(3, int(M.sqrt(n)) + 1, 2):
		while n % i == 0:
			maxPrime = i
			n = n / i
	if n > 2:
		maxPrime = n
	return int(maxPrime)

def countchar(s, i):
	c = 0
	ch = s[i]
	for i in range(i, len(s)):
		if s[i] == ch:
			c += 1
		else:
			break
	return c

def str_counter(a):
	q = [0] * 26
	for i in range(len(a)):
		q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
	return q

def lis(arr):
	n = len(arr)
	lis = [1] * n
	maximum = 0
	for i in range(1, n):
		for j in range(0, i):
			if arr[i] > arr[j] and lis[i] < lis[j] + 1:
				lis[i] = lis[j] + 1
				maximum = max(maximum, lis[i])
	return maximum

def lcm(arr):
	a = arr[0]
	val = arr[0]
	for i in range(1, len(arr)):
		gcd = gcd(a, arr[i])
		a = arr[i]
		val *= arr[i]
	return val // gcd

def ncr(n, r):
	return M.factorial(n) // (M.factorial(n - r) * M.factorial(r))

def npr(n, r):
	return M.factorial(n) // M.factorial(n - r)

def inint():
	return int(inp())

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

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

def instr():
	s = inp()
	return list(s)

def insarr():
	return inp().split()
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))
inp = lambda : sys.stdin.readline().rstrip('\r\n')
TestCases = 0

def solve():
	n = inint()
	res = 0
	q = 0
	for i in range(n):
		v = inint()
		if i == 0:
			res += abs(v - q) + 1
		else:
			res += abs(v - q) + 2
		q = v
	print(res)

def main():
	flag = 0
	try:
		sys.stdin = open('c:/Users/Manoj Chowdary/Documents/python/CodeForces/contest-div-2/input.txt', 'r')
		sys.stdout = open('c:/Users/Manoj Chowdary/Documents/python/CodeForces/contest-div-2/output.txt', 'w')
	except:
		flag = 1
	t = 1
	if TestCases:
		t = inint()
	for _ in range(1, t + 1):
		solve()
	if not flag:
		print('Time: %.4f sec' % (time.time() - start_time))
		localtime = time.asctime(time.localtime(time.time()))
		print(localtime)
		sys.stdout.close()
main()


n = int(input())
a = [0] * n
for i in range(n):
	a[i] = int(input())
seconds = a[0] + 1
for i in range(0, n - 1):
	if a[i] == a[i + 1]:
		seconds = seconds + 1
	elif a[i] < a[i + 1]:
		seconds = seconds + (a[i + 1] - a[i]) + 1
	else:
		seconds = seconds + (a[i] - a[i + 1]) + 1
	seconds = seconds + 1
print(seconds)


h = r = 0
for _ in [0] * int(input()):
	x = int(input())
	r += abs(x - h) + 2
	h = x
print(r - 1)


n = int(input())
arr = []
for i in range(n):
	arr.append(int(input()))
t = arr[0] + 1
for i in range(1, n):
	if arr[i] == arr[i - 1]:
		t = t + 2
	else:
		t = t + 2 + abs(arr[i] - arr[i - 1])
print(t)


n = int(input())
ans = 0
prev = 0
for _ in range(n):
	h = int(input())
	if prev == 0:
		ans += h + 1
	else:
		ans += 2 + abs(h - prev)
	prev = h
print(ans)


n = int(input())
curh = 0
total_time = 0
th = 0
a = []
for i in range(n):
	a.append(int(input()))
for i in range(n - 1):
	th = a[i]
	if th > curh:
		total_time += th - curh
		curh = th
	total_time += 1
	if th > a[i + 1]:
		total_time += th - a[i + 1]
		curh = a[i + 1]
	total_time += 1
th = a[n - 1]
if th > curh:
	total_time += th - curh
total_time += 1
print(total_time)


n = int(input())
p = 0
ans = 0
for i in range(n):
	k = int(input())
	ans += abs(k - p)
	p = k
print(ans + n + n - 1)


n = int(input())
a = int(input())
s = a
for i in range(n - 1):
	b = int(input())
	s += abs(b - a)
	a = b
print(s + 2 * n - 1)


n = int(input())
a = b = 0
for i in [0] * n:
	h = int(input())
	a += abs(h - b) + 2
	b = h
print(a - 1)


n = int(input())
h = []
for i in range(n):
	h.append(int(input()))
c = 0
t = 0
for i in h:
	t += abs(c - i) + 2
	c = i
print(t - 1)


n = int(input())
time = 2 * n - 1
h0 = 0
while n > 0:
	h = int(input())
	time += abs(h - h0)
	h0 = h
	n -= 1
print(time)


n = int(input())
ar = []
for x in range(n):
	ar.append(int(input()))
sum = n + n - 1
h = 0
for i in range(n):
	sum += abs(ar[i] - h)
	h = ar[i]
print(sum)


n = int(input())
first_tree = int(input())
cur_height = first_tree
steps = first_tree + 1
c = 0
while c < n - 1:
	next_tree = int(input())
	steps += 2
	if cur_height < next_tree:
		steps += next_tree - cur_height
	elif cur_height > next_tree:
		steps += cur_height - next_tree
	cur_height = next_tree
	c += 1
print(steps)


import sys

def deeznuts(n, t):
	s = 0
	cp = 0
	if n == 1:
		return t[0] + 1
	for i in range(n - 1):
		s = s + 1 + t[i] - cp
		if t[i] > t[i + 1]:
			s = s + 1 - t[i + 1] + t[i]
			cp = t[i + 1]
		if t[i] <= t[i + 1]:
			s = s + 1
			cp = t[i]
	if t[n - 1] > t[n - 2]:
		return s + t[n - 1] - t[n - 2] + 1
	return s + 1
input = sys.stdin.read()
data = list(map(int, input.split()))
n = data[0]
t = list(data[1:])
print(deeznuts(n, t))


from collections import deque, Counter, OrderedDict
from heapq import nsmallest, nlargest
from math import ceil, floor, log, log2, sqrt, gcd, factorial, pow, pi
from bisect import bisect_left, bisect_right

def binNumber(n, size=4):
	return bin(n)[2:].zfill(size)

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

def ini():
	return int(input())

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

def sti():
	return str(input())

def par(a):
	print(' '.join(list(map(str, a))))

def tdl(outerListSize, innerListSize, defaultValue=0):
	return [[defaultValue] * innerListSize for i in range(outerListSize)]

def sts(s):
	s = list(s)
	s.sort()
	return ''.join(s)

class pair:

	def __init__(self, f, s):
		self.fi = f
		self.se = s

	def __lt__(self, other):
		return (self.fi, self.se) < (other.fi, other.se)
n = ini()
h = []
cnt = 0
for i in range(n):
	h.append(ini())
cnt += h[0] + 2
for i in range(1, n):
	cnt += abs(h[i - 1] - h[i]) + 2
cnt -= 1
print(cnt)


(s, b) = (-1, 0)
for i in range(int(input())):
	k = int(input())
	s += abs(b - k) + 2
	b = k
print(s)


n = int(input())
li = []
for i in range(n):
	li.append(int(input()))
sum = li[0] + 1
for i in range(n - 1):
	if li[i] > li[i + 1]:
		sum += li[i] - li[i + 1] + 2
	else:
		diff = li[i + 1] - li[i]
		sum += diff + 2
print(sum)


n = int(input())
w = []
for i in range(n):
	w.append(int(input()))
cost = 2 * n - 1 + w[0]
for k in range(1, n):
	cost += abs(w[k] - w[k - 1])
print(cost)


I = lambda : int(input())
c = 0
total = -1
for i in [1] * I():
	b = I()
	total += abs(c - b) + 2
	c = b
print(total)


n = int(input())
sum1 = 0
for i in range(0, n):
	h = int(input())
	if i == 0:
		sum1 = sum1 + h
	elif i > 0:
		if prev > h:
			sum1 = sum1 + (prev - h)
		if prev < h:
			sum1 = sum1 + (h - prev)
	prev = h
sum1 = sum1 + n + n - 1
print(sum1)


t = []
x = int(input())
for _ in range(x):
	t.append(int(input()))
sum = t[0]
n = 0
while n < x:
	if n + 1 < x:
		sum += abs(t[n] - t[n + 1]) + 1
	n += 1
sum += x
print(sum)


n = int(input())
h = []
for i in range(n):
	h.append(int(input()))
time = h[0] + 1
for i in range(n - 1):
	if h[i] <= h[i + 1]:
		time += 1
	else:
		time += h[i] - h[i + 1] + 1
	time += h[i + 1] - min(h[i], h[i + 1])
	time += 1
print(time)


from collections import Counter, defaultdict
BS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'

def to_base(s, b):
	res = ''
	while s:
		res += BS[s % b]
		s //= b
	return res[::-1] or '0'
alpha = 'abcdefghijklmnopqrstuvwxyz'
from math import floor, ceil, pi
n = int(input())
nums = [int(input()) for i in range(n)]
tot = 0
pos = 0
height = 0
while pos < len(nums):
	cur = nums[pos]
	tot += cur - height + 1
	height = cur
	if pos == len(nums) - 1:
		break
	else:
		ne = nums[pos + 1]
		if ne < height:
			tot += height - ne
			height = ne
		tot += 1
	pos += 1
print(tot)


n = int(input())
a = []
for x in range(0, n):
	t = int(input())
	a.append(t)
d = a[0] + 1
for y in range(0, n - 1):
	if a[y + 1] == a[y]:
		d += 1
	else:
		d = d + abs(a[y + 1] - a[y]) + 1
	d += 1
print(d)


import os
import sys
from math import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
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')

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

def array():
	return [int(i) for i in input().split()]
t = int(input())
last = int(input())
ans = last + 1
for _ in range(t - 1):
	h = int(input())
	ans += 1
	if h < last:
		ans += last - h + 1
	elif h == last:
		ans += 1
	else:
		ans += 1 + h - last
	last = h
print(ans)


def solve():
	n = int(input())
	(c, s) = (0, 0)
	for i in range(n):
		t = int(input())
		c += abs(t - s)
		s = t
	print(c + 2 * n - 1)

def main():
	solve()
main()


n = int(input())
(res, step) = (0, 0)
for _ in range(n):
	h = int(input())
	res += 2 + abs(h - step)
	step = h
print(res - 1)


n = int(input())
a = []
for i in range(n):
	a.append(int(input()))
t = 0
for i in range(len(a)):
	if i == 0:
		t += a[i]
	elif a[i - 1] <= a[i]:
		t += 1
		t += a[i] - a[i - 1]
	else:
		t += a[i - 1] - a[i]
		t += 1
	t += 1
print(t)


n = int(input())
a = []
for i in range(n):
	a.append(int(input()))
sun = a[0]
for i in range(n):
	if i == n - 1:
		sun += 1
	elif a[i + 1] != a[i]:
		sun += 2 + abs(a[i] - a[i + 1])
	elif a[i + 1] == a[i]:
		sun += 2
print(sun)


n = int(input())
a = []
sum = 0
eat = 1
nxt = 1
for i in range(n):
	inp = int(input())
	a.append(inp)
	sum += eat
	if len(a) == 1:
		sum += a[0]
	else:
		sum += abs(a[len(a) - 1] - a[len(a) - 2])
		sum += nxt
print(sum)


n = int(input())
z = []
for i in range(n):
	x = int(input())
	z.append(x)
s = z[0] + 1
for i in range(1, len(z)):
	if z[i] < z[i - 1]:
		s += z[i - 1] - z[i] + 2
	elif z[i - 1] < z[i]:
		s += z[i] - z[i - 1] + 2
	elif z[i] == z[i - 1]:
		s += 2
print(s)


n = int(input())
x = 0
a = []
for i in range(n):
	h = int(input())
	a.append(h)
x += a[0] + 1
for i in range(1, n):
	if a[i] > a[i - 1]:
		x += a[i] - a[i - 1] + 2
	elif a[i] == a[i - 1]:
		x += 2
	else:
		x += a[i - 1] - a[i] + 2
print(x)


arr = list()
c = 0
n = int(input())
for i in range(int(n)):
	e = int(input())
	arr.append(int(e))
for i in range(int(n)):
	if i != 0:
		if arr[i - 1] == arr[i]:
			c = c + 2
		elif arr[i - 1] > arr[i]:
			c = c + (arr[i - 1] - arr[i]) + 2
		else:
			c = c + 1
			c = c + (arr[i] - arr[i - 1]) + 1
	else:
		c = c + arr[0] + 1
print(c)


import sys
inputlist = sys.stdin.readlines()
number_of_numbers = int(inputlist[0])
total_value = 0
value_before = 0
for i in range(1, number_of_numbers + 1):
	value_now = int(inputlist[i])
	diff = abs(value_now - value_before)
	total_value = total_value + diff
	value_before = value_now
print(total_value + 2 * number_of_numbers - 1)


n = int(input())
curr = 0
summ = 0
for i in range(n):
	new = int(input())
	summ += abs(new - curr)
	curr = new
	summ += 2
summ -= 1
print(summ)


def main():
	n = int(input())
	a = []
	for i in range(n):
		a.append(int(input()))
	cost = 0
	curr_high = 0
	for i in range(n):
		cost += abs(curr_high - a[i]) + 1
		if i + 1 < n:
			if a[i] <= a[i + 1]:
				cost += 1
				curr_high = a[i]
			else:
				cost += a[i] - a[i + 1] + 1
				curr_high = a[i + 1]
	print(cost)
main()


n = int(input())
num_units = 0
cur_height = 1
for i in range(n):
	h = int(input())
	if cur_height <= h:
		num_units += 1
		num_units += h - cur_height
		num_units += 1
		cur_height = h
	else:
		num_units += 1
		num_units += cur_height - h
		num_units += 1
		cur_height = h
print(num_units)


num = int(input())
tree = list()
i = num
while i > 0:
	t = input()
	tree.append(int(t))
	i = i - 1
time1 = num + tree[0]
for i in range(0, len(tree) - 1):
	if tree[i] <= tree[i + 1]:
		time1 = time1 + 1
		time1 = time1 + tree[i + 1] - tree[i]
	else:
		time1 = time1 + tree[i] - tree[i + 1] + 1
print(time1)


n = int(input())
t = []
for i in range(n):
	x = int(input())
	t.append(x)
count = 0
h = 0
for i in range(n):
	count += abs(h - t[i]) + 2
	h = t[i]
print(count - 1)


a = []
for x in range(int(input())):
	a.append(int(input()))
s = a[0] + 1
for x in range(1, len(a)):
	s += abs(a[x] - a[x - 1]) + 2
print(s)


t = int(input())
a = []
for i in range(t):
	a.append(int(input()))
c = 0
if len(a) == 1:
	print(a[0] + 1)
else:
	for j in range(len(a) - 1):
		if j == 0:
			c = c + a[0] + 1
		if a[j + 1] >= a[j]:
			c = c + a[j + 1] - a[j] + 1 + 1
		else:
			c = c + (a[j] - a[j + 1]) + 1 + 1
	print(c)


n = int(input())
arr = []
for _ in range(n):
	arr.append(int(input()))
time = 0
curr_height = 0
for i in arr:
	time += abs(i - curr_height) + 2
	curr_height = i
print(time - 1)


import math
n = int(input())
arr = []
for ii in range(n):
	a = int(input())
	arr.append(a)
h = 0
ans = 0
for i in range(n):
	ans += abs(h - arr[i]) + 1
	ans += 1
	h = arr[i]
ans -= 1
print(ans)


n = int(input())
arr = []
for i in range(n):
	arr.append(int(input()))
currheight = arr[0]
seconds = arr[0] + 1
for i in range(1, n):
	seconds += 1
	if arr[i] < currheight:
		seconds += currheight - arr[i] + 1
	else:
		seconds += arr[i] - currheight + 1
	currheight = arr[i]
print(seconds)


n = int(input())
z = []
for i in range(n):
	z.append(int(input()))
s = z[0] + 1
for i in range(1, len(z)):
	if z[i] > z[i - 1]:
		s = s + z[i] - z[i - 1] + 2
	else:
		s += z[i - 1] - z[i] + 2
print(s)


n = int(input())
p = int(input())
s = p + 1
for i in range(1, n):
	c = int(input())
	s += abs(p - c) + 2
	p = c
print(s)


n = int(input())
seconds = int(input()) + 1
s = seconds - 1
for x in range(n - 1):
	tree = int(input())
	seconds += abs(tree - s) + 2
	s = tree
print(seconds)


import sys
import math as m

def main():
	pass

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def lts(l):
	s = ''.join(map(str, l))
	return s

def stl(s):
	l = list(s)
	return l
mod = int(1000000000.0) + 7

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

def iinp():
	return int(input())

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

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

def p(a):
	print(a)

def p2(a, b):
	print(a, b)
n = iinp()
h = iinp()
t = h + 1
prev = h
for i in range(n - 1):
	h = iinp()
	diff = prev - h
	if diff < 0:
		t = t + 2 + abs(diff)
		prev = h
	elif diff == 0:
		t = t + 2
		prev = h
	else:
		t = t + abs(diff) + 1 + 1
		prev = h
print(t)


from sys import stdin

def inp():
	return stdin.readline().strip()
n = int(inp())
ar = []
for i in range(n):
	ar.append(int(inp()))
ans = 1 + ar[0]
for i in range(n - 1):
	ans += 2
	ans += abs(ar[i] - ar[i + 1])
print(ans)


n = int(input())
a = [0] * n
for i in range(n):
	a[i] = int(input())
ans = 0
prev = 0
for i in range(n):
	if prev >= a[i]:
		ans += 2 + prev - a[i]
	else:
		ans += 2 + a[i] - prev
	prev = a[i]
print(ans - 1)


n = int(input())
b = []
total_sum = 0
for i in range(n):
	ele = int(input())
	b.append(ele)
for i in range(n - 1):
	total_sum += abs(b[i] - b[i + 1]) + 1
print(b[0] + total_sum + n)


size = int(input())
height = []
for i in range(size):
	temp = int(input())
	height.append(temp)
steps = 0
for i in range(size):
	if i == 0:
		steps += height[i] + 1
	elif height[i] < height[i - 1]:
		steps += height[i - 1] - height[i] + 1 + 1
	else:
		steps += 1 + (height[i] - height[i - 1]) + 1
print(steps)


n = int(input())
h = int(input())
ans = h + n
prev = h
for i in range(n - 1):
	h = int(input())
	if h >= prev:
		ans += h - prev + 1
	else:
		ans += prev - h + 1
	prev = h
print(ans)


n = int(input())
p = 0
k = 0
for i in range(n):
	v = int(input())
	if p == 0:
		p = v
		k = k + v + 1
	elif p <= v:
		k = k + 2 + abs(p - v)
		p = v
	else:
		k = k + 2 + abs(p - v)
		p = v
print(k)


n = int(input())
l = []
for _ in range(n):
	l.append(int(input()))
time = len(l)
if len(l) == 1:
	print(time + l[0])
else:
	for i in range(len(l) - 1):
		if i == 0:
			time += l[i]
		if l[i + 1] < l[i]:
			time += l[i] - l[i + 1]
			time += 1
		elif l[i] == l[i + 1]:
			time += 1
		elif l[i] < l[i + 1]:
			time += 1
			time += l[i + 1] - l[i]
	print(time)


class CodeforcesTask265BSolution:

	def __init__(self):
		self.result = ''
		self.n = 0
		self.trees = []

	def read_input(self):
		self.n = int(input())
		for x in range(self.n):
			self.trees.append(int(input()))

	def process_task(self):
		time = self.n * 2 - 1
		time += self.trees[0]
		pos = self.trees[0]
		for x in range(self.n - 1):
			if pos <= self.trees[x + 1]:
				time += self.trees[x + 1] - pos
				pos = self.trees[x + 1]
			else:
				time += pos - self.trees[x + 1]
				pos = self.trees[x + 1]
		self.result = str(time)

	def get_result(self):
		return self.result
Solution = CodeforcesTask265BSolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


(pre, ans) = (0, -1)
for i in range(int(input())):
	n = int(input())
	ans += abs(n - pre)
	ans += 2
	pre = n
print(ans)


n = int(input())
d = []
for k in range(n):
	d.append(int(input()))
a = d[0] + 1
for k in range(n - 1):
	if d[k] > d[k + 1]:
		a += d[k] - d[k + 1] + 2
	else:
		a += d[k + 1] - d[k] + 2
print(a)


n = int(input())
arr = []
for j in range(n):
	elem = int(input())
	arr.append(elem)
t = arr[0] + 1
for i in range(1, len(arr)):
	if arr[i] > arr[i - 1]:
		t += arr[i] - arr[i - 1] + 2
	else:
		t += arr[i - 1] - arr[i] + 2
print(t)


(x, t) = (0, 0)
for i in range(int(input())):
	n = int(input())
	if x <= n:
		t = t + n - x + 1
		if x > 0:
			t = t + 1
	else:
		t = t + x - n + 2
	x = n
print(t)


n = int(input())
h = int(input())
s = h + 1
for i in range(n - 1):
	a = int(input())
	if h == a:
		s += 2
	elif h > a:
		s += h - a + 2
	elif h < a:
		s += 1 + a - h + 1
	h = a
print(s)


n = int(input())
ans = 0
for i in range(n):
	h = int(input())
	if i == 0:
		ans += h
		if n == 1:
			ans += 1
		else:
			ans += 2
		prev = h
	elif i == n - 1:
		ans += abs(prev - h)
		ans += 1
	else:
		ans += abs(prev - h)
		ans += 2
		prev = h
print(ans)


n = int(input())
m = int(input())
s = 0
s += m + 1
for i in range(n - 1):
	a = int(input())
	if a >= m:
		s += a - m + 2
	else:
		s += m - a + 2
	m = a
print(s)


import math
from collections import *
import sys
from functools import reduce

def get_ints():
	return map(int, input().strip().split())

def get_list():
	return list(get_ints())

def get_string():
	return list(input().strip().split())

def printxsp(*args):
	return print(*args, end='')

def printsp(*args):
	return print(*args, end=' ')
UGLYMOD = int(1000000000.0) + 7
SEXYMOD = 998244353
MAXN = int(100000.0)
N = int(input())
li = []
for i in range(N):
	li.append(int(input()))
t = li[0]
prev = li[0]
for i in range(1, N):
	if li[i] >= prev:
		t += li[i] - prev + 1
	else:
		t += prev - li[i] + 1
	prev = li[i]
print(t + N)


n = int(input())
prev = int(input())
t = prev + 1
for i in range(n - 1):
	next = int(input())
	t += abs(next - prev) + 2
	prev = next
print(t)


x = []
a = int(input())
for i in range(a):
	x.append(int(input()))
cnt = x[0]
for i in range(1, len(x)):
	cnt += abs(x[i - 1] - x[i]) + 1
print(cnt + a)


def steps(lst):
	start = 0
	total = 0
	for i in range(len(lst)):
		total += abs(start - lst[i])
		start = lst[i]
		total += 1
		if i != len(lst) - 1:
			total += 1
	return total
lst = []
for _ in range(int(input())):
	lst.append(int(input()))
print(steps(lst))


n = int(input())
j = 0
l = 0
for i in range(n):
	L = int(input())
	l += int(i > 0) + abs(L - j) + 1
	j = L
print(l)


n = int(input())
height = []
for i in range(n):
	height.append(int(input()))
s = height[0] + 1
h = height[0]
for i in range(1, n):
	if height[i] == h:
		s += 2
	elif height[i] < h:
		s += h - height[i] + 2
		h = height[i]
	else:
		s += 2 + height[i] - h
		h = height[i]
print(s)


n = int(input())
arr = []
for i in range(n):
	arr.append(int(input()))
t1 = arr[0] + 1
i = 0
while i < n - 1:
	if arr[i] <= arr[i + 1]:
		t1 = t1 + (arr[i + 1] - arr[i]) + 2
	else:
		t1 = t1 + (arr[i] - arr[i + 1]) + 2
	i = i + 1
print(t1)


n = int(input())
c = 0
l = []
for i in range(n):
	m = int(input())
	if len(l) == 0:
		c += m + 1
		l.append(m)
	else:
		if l[-1] <= m:
			r = m - l[-1]
			c += r + 2
		else:
			r = l[-1] - m
			c += r + 2
		l.append(m)
print(c)


n = int(input())
l = [0] * n
for i in range(n):
	l[i] = int(input())
q = 2 * n - 1 + l[0]
for i in range(1, n):
	q += abs(l[i] - l[i - 1])
print(q)


n = int(input())
h = []
for i in range(n):
	h.append(int(input()))
start = 0
ans = 0
for i in range(n):
	ans += abs(h[i] - start) + 1
	start = h[i]
	if i > 0:
		ans += 1
print(ans)


def main():
	(cur, val) = (0, -1)
	for i in range(int(input())):
		h = int(input())
		val += abs(cur - h) + 2
		cur = h
	print(val)
main()


n = int(input())
a = []
for _ in range(n):
	a.append(int(input()))
t = a[0]
for i in range(n - 1):
	if a[i + 1] >= a[i]:
		t += a[i + 1] - a[i] + 1
	else:
		t += a[i] - a[i + 1] + 1
print(t + n)


n = int(input().strip())
h = []
for i in range(n):
	h.append(int(input().strip()))
t = 0
t += h[0] + 1
for i in range(n - 1):
	if h[i + 1] == h[i]:
		t += 2
	else:
		t += abs(h[i + 1] - h[i]) + 2
print(t)


s = 0
c = 0
for _ in ' ' * int(input()):
	a = int(input())
	s += abs(c - a) + 2
	c = a
print(s - 1)


(cur_height, ans) = (0, 0)
for i in range(int(input())):
	x = int(input())
	if i == 0:
		ans += x + 1
		cur_height = x
	elif cur_height < x:
		ans += x - cur_height + 2
		cur_height = x
	else:
		ans += cur_height - x + 2
		cur_height = x
print(ans)


n = int(input())
l = []
for i in range(n):
	a = int(input())
	l.append(a)
t = 0
for i in range(n):
	if i == 0:
		t = t + l[i] + 1
	elif l[i] < l[i - 1]:
		k = l[i - 1] - l[i]
		t = t + k + 2
	elif l[i] > l[i - 1]:
		k = l[i] - l[i - 1]
		t = t + 2 + k
	elif l[i] == l[i - 1]:
		t = t + 2
print(t)


n = int(input())
heights = [int(input()) for n in range(n)]
jumpTime = 1
eatTime = 1
previousHeight = 0
totalTime = 0
for height in heights:
	if previousHeight <= height:
		totalTime += height - previousHeight + eatTime
		if previousHeight != 0:
			totalTime += jumpTime
	else:
		totalTime += previousHeight - height + eatTime + jumpTime
	previousHeight = height
print(totalTime)


a = []
for _ in range(int(input())):
	a.append(int(input()))
count = a[0]
for i in range(len(a) - 1):
	count += 1
	count += abs(a[i + 1] - a[i]) + 1
print(count + 1)


n = int(input())
lis = []
for i in range(n):
	temp = int(input())
	lis.append(temp)
ans = len(lis)
ans += lis[0]
for i in range(n - 1):
	ans += abs(lis[i] - lis[i + 1]) + 1
print(ans)


t = -1
z = 0
for i in range(int(input())):
	a = int(input())
	if z != a:
		t += 1
		t += abs(a - z)
		t += 1
	else:
		t += 2
	z = a
print(t)


n = int(input())
h = []
for _ in range(n):
	h.append(int(input()))
if n == 1:
	print(h[0] + 1)
else:
	curh = 0
	curt = 0
	for i in range(n - 1):
		curt += h[i] - curh + 2
		curh = h[i]
		if h[i] > h[i + 1]:
			curt += h[i] - h[i + 1]
			curh = h[i + 1]
	if h[n - 1] > curh:
		curt += h[n - 1] - curh
	curt += 1
	print(curt)


def sol(arr, n):
	sec = arr[0] + 1
	for i in range(1, n):
		if arr[i - 1] <= arr[i]:
			sec += 2 + (arr[i] - arr[i - 1])
		else:
			sec += arr[i - 1] - arr[i] + 2
	print(sec)
	return
n = int(input())
arr = []
for t in range(n):
	arr.append(int(input()))
sol(arr, n)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
import copy
import time
starttime = time.time()
mod = int(pow(10, 9) + 7)
mod2 = 998244353

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

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def L():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
try:
	sys.stdin = open('input.txt', 'r')
except:
	pass
n = L()[0]
A = [L()[0] for i in range(n)]
ans = A[0] + 1
for i in range(1, n):
	ans += abs(A[i] - A[i - 1])
	ans += 2
print(ans)
endtime = time.time()


t = int(input())
time = t + t - 1
h0 = 0
for i in range(t):
	h = int(input())
	time += abs(h - h0)
	h0 = h
print(time)


def zip_sorted(a, b):
	(a, b) = zip(*sorted(zip(a, b)))
	sorted(zip(a, b), key=lambda x: x[1])
	return (a, b)
n = int(input())
h = [0] * n
for i in range(n):
	h[i] = int(input())
sum1 = 0
h_prev = 0
i = 0
for k1 in range(len(h)):
	sum1 = sum1 + abs(h[k1] - h_prev)
	sum1 = sum1 + k1 - i
	sum1 = sum1 + 1
	h_prev = h[k1]
	i = k1
print(sum1)


n = int(input())
b = n + (n - 1)
c = []
for i in range(n):
	a = int(input())
	c.append(a)
for i in range(1, n):
	b += abs(c[i] - c[i - 1])
print(b + c[0])


import sys
INT_MAX = sys.maxsize
INT_MIN = -sys.maxsize - 1
sys.setrecursionlimit(10 ** 7)
mod = 1000000007

def IOE():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def main():
	inp = []
	n = int(sys.stdin.readline())
	for _ in range(n):
		inp.append(int(sys.stdin.readline()))
	ans = 0
	inp.insert(0, 1)
	for i in range(len(inp) - 1):
		ans = ans + abs(inp[i + 1] - inp[i]) + 1
	print(ans + n)
try:
	IOE()
except:
	pass
main()


class Task:
	h = []
	answer = 0

	def getData(self):
		h_size = int(input())
		self.h = [int(input()) for i in range(h_size)]

	def solve(self):
		current_level = 0
		for i in range(0, len(self.h)):
			self.answer += self.h[i] - current_level + 1
			if i == len(self.h) - 1:
				return
			if self.h[i + 1] < self.h[i]:
				self.answer += self.h[i] - self.h[i + 1]
				current_level = self.h[i + 1]
			else:
				current_level = self.h[i]
			self.answer += 1

	def printAnswer(self):
		print(self.answer)
task = Task()
task.getData()
task.solve()
task.printAnswer()


n = int(input())
heigth = int(input())
ans = heigth + 1
for i in range(n - 1):
	target = int(input())
	ans += abs(heigth - target) + 2
	heigth = target
print(ans)


n = int(input())
c_h = 0
t = 0
for i in range(n):
	h = int(input())
	if h >= c_h:
		t += h - c_h
		c_h = h
	else:
		t += c_h - h
		c_h = h
	t += 2
t -= 1
print(t)


def main():
	n = int(input())
	heights = [0 for _ in range(n)]
	for i in range(n):
		heights[i] = int(input())
	current_height = 0
	current_time = 0
	current_tree = 0
	while current_tree < n:
		current_time += abs(heights[current_tree] - current_height)
		current_height = heights[current_tree]
		current_time += 1
		if current_tree < n - 1:
			current_time += 1
		current_tree += 1
	print(current_time)
main()


n = int(input())
h = int(input())
ans = n + h
for _ in range(n - 1):
	height = int(input())
	ans += abs(height - h) + 1
	h = height
print(ans)


n = int(input())
tmp = 0
h = []
while tmp < n:
	tmp = tmp + 1
	h.append(int(input()))
ans = h[0]
tmp = 1
while tmp < n:
	ans += abs(h[tmp] - h[tmp - 1])
	tmp = tmp + 1
print(ans + n + n - 1)


n = int(input())
time = 0
last = 0
for i in range(n):
	j = int(input())
	time += abs(j - last)
	last = j
print(time + n + n - 1)


t = int(input())
sum = 2 * t - 1
b = 0
while t > 0:
	a = int(input())
	sum += abs(a - b)
	b = a
	t -= 1
print(sum)


from sys import stdin, stdout

def solve(n, trees):
	sec = trees[0] + 1
	for i in range(1, n):
		sec += 1 + 1 + abs(trees[i] - trees[i - 1])
	return sec
n = int(stdin.readline().rstrip())
trees = []
counter = n
while counter:
	counter -= 1
	trees.append(int(stdin.readline().rstrip()))
stdout.write(str(solve(n, trees)))


def seconds(l):
	time = 0
	h = 0
	for i in range(len(l) - 1):
		if h < l[i]:
			time += l[i] - h
			h += l[i] - h
		time += 1
		if h > l[i + 1]:
			time += h - l[i + 1]
			h -= h - l[i + 1]
		time += 1
	if h < l[-1]:
		time += l[-1] - h
		h += l[-1] - h
	time += 1
	return time
m = int(input())
l = []
for i in range(m):
	l.append(int(input()))
print(seconds(l))


n = int(input())
hp = int(input())
k = hp + 1
for i in range(1, n):
	hc = int(input())
	if hp <= hc:
		k += hc - hp + 2
	else:
		k += hp - hc + 2
	hp = hc
print(k)


t = 0
d = 0
l = []
n = int(input())
for i in range(n):
	l.append(int(input()))
	t += abs(l[i] - d) + 2
	d = l[i]
print(t - 1)


n = int(input())
a = 0
b = 0
while n > 0:
	s = int(input())
	a = a + abs(s - b)
	a = a + 1
	b = s
	if n != 1:
		a = a + 1
	n = n - 1
print(a)


def main():
	from sys import stdin, stdout
	n = int(stdin.readline())
	ksum = n
	for i in range(n):
		x = int(stdin.readline())
		if i:
			if x < p:
				ksum += 1 + (p - x)
				p = x
			else:
				ksum += 1 + x - p
				p = x
		else:
			ksum += x
			p = x
	stdout.write(str(ksum))
main()


n = int(input())
h = []
for i in range(n):
	h.append(int(input()))
t = 0
h1 = 0
for i in range(n - 1):
	if h[i] > h1:
		t += h[i] - h1
		h1 = h[i]
	t += 1
	if h[i + 1] >= h1:
		t += 1
	else:
		t += h1 - h[i + 1]
		h1 = h[i + 1]
		t += 1
if h[n - 1] > h1:
	t += h[n - 1] - h1
	h1 = h[n - 1]
	t += 1
else:
	t += 1
print(t)


from sys import stdin, stdout
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007
n = ii1()
arr = []
for _ in range(n):
	arr.append(ii1())
res = arr[0] + 1
for i in range(1, n):
	if arr[i - 1] > arr[i]:
		res += arr[i - 1] - arr[i]
	else:
		res += arr[i] - arr[i - 1]
	res += 2
print(res)


n = int(input())
cur = 0
sum = 0
for i in range(n):
	nxt = int(input())
	sum += abs(nxt - cur)
	cur = nxt
	sum += 1
	if i + 1 < n:
		sum += 1
print(sum)


from sys import stdin
n = int(stdin.readline())
trees = []
for i in range(0, n):
	trees.append(int(stdin.readline()))
trees.append(10001)
time = 0
height = 0
for i in range(0, n):
	time += trees[i] - height + 1
	height = trees[i]
	time += max(0, height - trees[i + 1]) + 1
	height = min(height, trees[i + 1])
print(time - 1)


n = int(input())
h = []
for _ in range(n):
	h.append(int(input()))
c = h[0]
d = h[0]
for i in range(1, n):
	d = d + abs(h[i] - c)
	c = h[i]
print(d + 2 * n - 1)


n = int(input())
time = 0
prev = 0
for i in range(n):
	x = int(input())
	if x > prev:
		time += x - prev + 1
		prev = x
	else:
		time += prev - x + 1
		prev = x
print(time + n - 1)


n = int(input())
l = []
a = 0
for _ in range(n):
	h = int(input())
	if h >= a:
		l.append(1 + (h - a) + 1)
	else:
		l.append(a - h + 1 + 1)
	a = h
print(sum(l) - 1)


n = int(input())
arr = []
for i in range(n):
	arr.append(int(input()))
time = arr[0] + 1
for i in range(n - 1):
	diff = abs(arr[i] - arr[i + 1])
	time += diff + 2
print(time)


n = int(input())
time = n + n - 1
hi = 0
for i in range(0, n):
	hf = int(input())
	time += abs(hf - hi)
	hi = hf
print(time)


n = int(input())
ans = n + n - 1
normal = []
sub = []
for i in range(n):
	normal.append(int(input()))
	if i == 0:
		sub.append(normal[0])
	else:
		sub.append(abs(normal[i] - normal[i - 1]))
for x in sub:
	ans += x
print(ans)


n = int(input())
res = n
cur = 0
for i in range(n):
	temp = int(input())
	res += abs(temp - cur)
	cur = temp
	if i != n - 1:
		res += 1
print(res)


ts = []
for _ in range(int(input())):
	q = int(input())
	ts.append(q)
h = 1
h1 = ts[0]
tiller = 0
for i in range(1, len(ts) + 1):
	if i != len(ts):
		h2 = ts[i]
	else:
		h2 = h1
		tiller -= 1
	tiller += h1 - h + 2
	if h1 == h2 or h1 > h2:
		tiller += h1 - h2
		h = h2
	else:
		h = h1
	h1 = h2
print(tiller + 1)


n = int(input())
h = []
for i in range(n):
	h.append(int(input()))
c = 0
i = 0
t = 0
while i < n - 1:
	t += h[i] - c
	c = h[i]
	t += 1
	if h[i + 1] < h[i]:
		t += h[i] - h[i + 1]
		c = h[i + 1]
	t += 1
	i += 1
t += h[i] - c + 1
print(t)


l = [int(input()) for i in range(int(input()))]
print(sum([abs(l[i] - l[i - 1]) if i > 0 else l[i] for i in range(len(l))]) + (2 * len(l) - 1))


n = int(input())
lst = []
for i in range(n):
	x = int(input())
	lst.append(x)
cnt = 0
for i in range(n - 1):
	cnt += abs(lst[i] - lst[i + 1])
print(cnt + lst[0] + (n - 1) * 2 + 1)


n = int(input())
tree = []
for q in range(n):
	a = input()
	a = int(a)
	tree.append(a)
time = 0
time += tree[0]
time += 1
for a in range(1, len(tree)):
	if tree[a] > tree[a - 1]:
		time += tree[a] - tree[a - 1]
		time += 2
	elif tree[a] < tree[a - 1]:
		time += tree[a - 1] - tree[a]
		time += 2
	else:
		time += 2
print(time)


import sys
input = sys.stdin.readline
n = int(input())
x = int(input())
count = x + 1
while n - 1:
	n -= 1
	y = int(input())
	count += abs(x - y) + 2
	x = y
print(count)


n = int(input())
h = []
for i in range(n):
	g = int(input())
	h.append(g)
t = h[0] + 1
for j in range(n - 1):
	t += abs(h[j + 1] - h[j]) + 1 + 1
print(t)


def main():
	n = int(input())
	cur_h = 0
	res = 0
	for _ in range(n):
		h = int(input())
		res += abs(cur_h - h)
		cur_h = h
	print(res + n * 2 - 1)
main()


n = int(input())
arr = []
for i in range(0, n):
	arr.append(int(input()))
pos = 0
step = 0
for i in range(0, n):
	if arr[i] >= pos:
		step = step + abs(arr[i] - pos)
		pos = arr[i]
	elif arr[i] <= pos:
		step = step + abs(pos - arr[i])
		pos = arr[i]
step += 2 * n - 1
print(step)


n = int(input())
X = []
for i in range(n):
	X.append(int(input()))
c = n + X[0]
for i in range(n - 1):
	if X[i + 1] == X[i]:
		c = c + 1
	else:
		c = c + abs(X[i + 1] - X[i])
		c = c + 1
print(c)


t = int(input())
h = []
for i in range(t):
	x = int(input())
	h.append(x)
total = h[0]
for i in range(1, t):
	total = total + abs(h[i] - h[i - 1]) + 1
total = total + t
print(total)


import os, sys
from io import BytesIO, IOBase

def main():
	n = int(input())
	x = int(input())
	ans = x + 1
	for i in range(n - 1):
		y = int(input())
		ans += abs(x - y) + 2
		x = y
	print(ans)
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')
main()


n = int(input())
a = []
for i in range(n):
	k = int(input())
	a.append(k)
l = a[0]
for i in range(len(a) - 1):
	if a[i + 1] >= a[i]:
		l += a[i + 1] - a[i] + 1
	else:
		l += a[i] - a[i + 1] + 1
print(l + len(a))


t = int(input())
l = []
for i in range(t):
	n = int(input())
	l.append(n)
time = 0
m = 0
for i in range(t):
	if m == 0:
		time += l[i] + 1
		m = l[i]
	elif m < l[i]:
		time += l[i] - m + 2
		m = l[i]
	elif m >= l[i]:
		time += m - l[i] + 2
		m = l[i]
print(time)


import math
import itertools
import collections

def getdict(n):
	d = {}
	if type(n) is list:
		for i in n:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
	else:
		for i in range(n):
			t = ii()
			if t in d:
				d[t] += 1
			else:
				d[t] = 1
	return d

def cdiv(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

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

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

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)
n = ii()
h0 = ii()
ans = n + h0
for i in range(n - 1):
	h = ii()
	ans += abs(h - h0) + 1
	h0 = h
print(ans)


N = int(input())
SUM = 0
Last = 0
for i in range(N):
	X = int(input())
	SUM += abs(Last - X) + 2
	Last = X
print(SUM - 1)


import sys
f = sys.stdin
n = f.readline()
h = [int(i) for i in f.read().strip().split('\n')]
count = h[0] + 1
prev = h[0]
for i in range(1, len(h)):
	if h[i] > prev:
		count += h[i] - prev + 2
		prev = h[i]
	elif h[i] < prev:
		count += prev - h[i] + 2
		prev = h[i]
	elif h[i] == prev:
		count += 2
print(count)


import time, math
from sys import stdin, stdout

def I():
	return int(stdin.readline())

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

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

def Si():
	return sorted(list(map(int, stdin.readline().split())))

def Si():
	return sorted(list(map(int, stdin.readline().split())), reverse=True)

def P(x):
	return stdout.write(str(x))

def Pi(x, y):
	return stdout.write(str(x) + ' ' + str(y))

def solve():
	n = I()
	boo = I()
	ans = boo + 1
	for i in range(n - 1):
		t = I()
		ans += 2
		if t != boo:
			ans += abs(boo - t)
			boo = t
	P(ans)
solve()


n = int(input())
A = []
for i in range(n):
	A += [int(input())]
an = A[0]
for i in range(1, len(A)):
	an += abs(A[i] - A[i - 1])
an += 2 * n - 1
print(an)


n = int(input())
a = list((int(input()) for i in range(n)))
s = a[0]
for i in range(1, n):
	s += abs(a[i - 1] - a[i]) + 1
print(s + n)


import sys
inf = float('inf')
(mod, MOD) = (1000000007, 998244353)
from math import ceil, floor, log, sqrt, factorial, pow, pi, gcd, log10, atan, tan

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

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

def get_strs():
	return map(str, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
n = int(input())
Arr = []
for i in range(n):
	Arr.append(int(input()))
ans = Arr[0] + 1
curr = Arr[0]
for i in range(1, n):
	ans += abs(curr - Arr[i]) + 2
	curr = Arr[i]
print(ans)


def inpNum():
	return int(input())

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

def inpList():
	return list(map(int, input().split()))
n = inpNum()
total = n
prev = inpNum()
total += prev
for _ in range(n - 1):
	num = inpNum()
	total += abs(prev - num)
	prev = num
	total += 1
print(total)


n = int(input())
t = int(input())
a = t + 1
for i in range(n - 1):
	sig = int(input())
	a += abs(sig - t) + 2
	t = sig
print(a)


n = int(input())
x = []
for i in range(n):
	x.append(int(input()))
y = [x[0]]
for i in range(1, n):
	if x[i - 1] > x[i]:
		y.append(x[i - 1] - x[i] + 1)
	else:
		y.append(x[i] - x[i - 1] + 1)
ans = 0
for i in y:
	ans += i
print(ans + n)


n = int(input())
h = [int(input()) for i in range(n)]
now = h[0]
ans = h[0] + 1
for i in range(1, n):
	if h[i] >= now:
		ans += h[i] - now + 2
		now = h[i]
	else:
		ans += now - h[i] + 2
		now = h[i]
print(ans)


from math import ceil
n = int(input())
a = []
for i in range(n):
	x = input()
	a.append(int(x))
c = a[0] + 1
for i in range(1, n):
	if a[i] >= a[i - 1]:
		diff = a[i] - a[i - 1]
		c = c + 2 + diff
	else:
		diff = a[i - 1] - a[i]
		c = c + diff + 2
print(c)


H = []
steps = 0
for i in range(int(input())):
	if len(H) == 0:
		m = int(input())
		H.append(m)
		steps += m + 1
	else:
		m = int(input())
		steps += abs(H[-1] - m) + 2
		H.append(m)
print(steps)


n = int(input())
a = list()
for i in range(n):
	a.append(int(input()))
res = 0
h = 0
for i in range(n - 1):
	res += a[i] - h + 1
	if a[i] > a[i + 1]:
		res += a[i] - a[i + 1]
		res += 1
		h = a[i + 1]
	else:
		res += 1
		h = a[i]
res += 1
res += a[n - 1] - h
print(res)


no_tree = int(input())
len_tree = []
for i in range(no_tree):
	len_tree.append(int(input()))
time = 0
if len(len_tree) == 1:
	time = len_tree[0] + 1
else:
	for i in range(no_tree - 1):
		if i == 0:
			time += len_tree[i] + 1
		if len_tree[i] <= len_tree[i + 1]:
			time += abs(len_tree[i] - len_tree[i + 1]) + 2
		elif len_tree[i] > len_tree[i + 1]:
			time += abs(len_tree[i] - len_tree[i + 1]) + 2
print(time)