#include <bits/stdc++.h>
#define dp second
#define x first
using namespace std;
typedef pair<int,int> ii;
const int inf = 1023456;

int A[200005];
int dp[200005]; ///dp[i][0] 
int h1[200005]; ///smallest j such that dp[i][j] = dp[i][0] - 1  
int h2[200005]; ///smallest j such that dp[i][j] = dp[i][0] - 2  

inline int cost(int i, int x1, int x2){
	int y1 = A[i-1] - x1, y2 = A[i] - x2;
	return (x1 > x2) + (y1 < y2);
}

signed main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	
	int n; cin >> n;
	for(int i = 1;i <= n;i++) cin >> A[i];
	
	fill(dp,dp+200005,inf); dp[0] = 0;
	h1[0] = inf; h2[0] = inf;
			
	for(int i = 1;i <= n+1;i++){
		vector<ii> pre = { ii(0,dp[i-1]) };
		if(h1[i-1] != inf) pre.push_back(ii(h1[i-1], dp[i-1] - 1));
		if(h2[i-1] != inf) pre.push_back(ii(h2[i-1], dp[i-1] - 2));
		
		for(ii p : pre) dp[i] = min(dp[i], p.dp + cost(i, p.x, 0));
		
		int bestDP = inf;
		for(ii p : pre) bestDP = min(bestDP, p.dp + cost(i, p.x, A[i]));
		

		if(bestDP <= dp[i] - 1){
			
			///binary search for h1[i]
			int low = 0, high = A[i];
			while(low != high - 1){
				int s = (low + high) / 2;
				int val = inf;
				for(ii p : pre) val = min(val, p.dp + cost(i, p.x, s));
				if(val > dp[i] - 1) low = s;
				else high = s;
			}
			
			h1[i] = high;
		}
		else h1[i] = inf; ///not possible to achieve dp[i][0] - 1
		
		
		if(bestDP <= dp[i] - 2){
			
			///binary search for h2[i]
			int low = 0, high = A[i];
			while(low != high - 1){
				int s = (low + high) / 2;
				int val = inf;
				for(ii p : pre) val = min(val, p.dp + cost(i, p.x, s));
				if(val > dp[i] - 2) low = s;
				else high = s;
			}
			
			h2[i] = high;
		}
		else h2[i] = inf; ///not possible to achieve dp[i][0] - 2
	}
	
	cout << dp[n+1];
}
