#include<bits/stdc++.h>
#define cs const
#define pb push_back
using namespace std;
cs int N = 2e5 + 50;
cs int INF = 1e9 + 7;
int n, a[N];
struct my{ 
	int l, r, v; 
	bool emp(){ return l > r; }
	my(int _l = 0, int _r = 0, int _v = 0){
		l = _l, r = _r, v = _v;
	} my operator & (cs my &a){ return my(max(l,a.l),min(r,a.r), v); }
	bool operator < (cs my &a) cs{ return v < a.v; }
	my operator ^ (cs my &a){ return l == a.l ? my(a.r + 1, r, v) : my(l, a.l - 1, v); }
};
int main(){
	#ifdef FSYolanda
	freopen("1.in","r",stdin);
	#endif
	scanf("%d",&n);
	for(int i=1; i<=n; i++)
	scanf("%d",&a[i]);
	vector<my> now, nxt;
	now.pb(my(0, 0, 0));
	for(int i=1; i<=n+1; i++){
		nxt.clear(); int dt = a[i] - a[i-1];
		my lm(0, a[i]); 
		for(my t : now){
			my z = my(0, min(t.r - 1, t.r - 1 + dt), t.v + 2) & lm;
			if(!z.emp()) nxt.pb(z);
			z = my(t.l + dt, t.r - 1, t.v + 1) & lm;
			if(!z.emp()) nxt.pb(z);
			z = my(t.l, t.r + dt - 1, t.v + 1) & lm;
			if(!z.emp()) nxt.pb(z);
			z = my(max(t.l, t.l + dt), a[i], t.v) & lm;
			if(!z.emp()) nxt.pb(z);
		} sort(nxt.begin(), nxt.end());
		now.clear();
		for(my t : nxt){
			my z = t; for(my o : now){
				my p = o & z;
				if(!p.emp()) z = z ^ p;
				if(z.emp()) break;
			} if(!z.emp()) now.pb(z);
		}
	} int ans = INF;
	for(my t : now) ans = min(ans, t.v);
	cout << ans; return 0;
}