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

Difficulty: interview

Starter code:

Solutions:
#python33

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()       


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())
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)


import sys
f = sys.stdin
#f = open("input.txt", "r")
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)

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


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)

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)

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)


# problem 9
# Start 8:39
def seconds(l):
    time = 0
    h = 0
    for i in range(len(l) - 1):
        # Climb the tree
        if h < l[i]:
            time += l[i] - h
            h += l[i] - h

        # eat
        time += 1

        # get down to the height of th enext tree
        if h > l[i+1]:
            time += h - l[i+1]
            h -= h - l[i+1]

        # jump to the next tree
        time += 1

    # the last tree
    # Climb the tree
    if h < l[-1]:
        time += l[-1] - h
        h += l[-1] - h
    # eat
    time += 1

    return time

m = int(input())
l = []
for i in range(m):
    l.append(int(input()))
print(seconds(l))

# End 8:56
# Total 17 min


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())
r=n*2-1
h=0
for i in range(n):
 t=int(input())
 r+=abs(h-t)
 h=t
print(r)


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)

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

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))
        


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())
j=0
l=0
for i in range(n):
    L=int(input())
    l+=int(i>0)+abs(L-j)+1
    j=L
print(l)
        


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


def __starting_point():
    main()
__starting_point()

# coding: utf-8
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())
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)


#!/usr/bin/env python  
# coding=utf-8
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)



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)))


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


def __starting_point():
    main()
__starting_point()

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


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


def __starting_point():
    main()
__starting_point()

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()