#include <bits/stdc++.h>

using namespace std;

const int maxn = 200010;
typedef pair<int,int> pi;

int n, a[maxn];

vector<pi> cal(int lasta, int lastb, int s, int _) {
	vector<pi> ret;
	// 先判断是否可能不增加
	// x >= lasta, s - x <= lastb
	// x >= lasta, x >= s - lastb;
	if (max(lasta, s - lastb) <= s) ret.push_back(make_pair(_, max(lasta, s - lastb)));
	// 再判断只增加一项，x 的最小值（显然可以只增加一项）
	ret.push_back(pi(_ + 1, max(0, min(lasta, s - lastb))));
	ret.push_back(pi(_ + 2, 0));
	return ret;
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	pi mn0(0, 0), mn1(0, 0), mn2(0, 0);
	for (int i = 1; i <= n+1; i++) {
		vector<pi> v0 = cal(mn0.second, a[i-1] - mn0.second, a[i], mn0.first);
		vector<pi> v1 = cal(mn1.second, a[i-1] - mn1.second, a[i], mn1.first);
		vector<pi> v2 = cal(mn2.second, a[i-1] - mn2.second, a[i], mn2.first);
		vector<pi> ch;
		ch.insert(ch.end(), v0.begin(), v0.end());
		ch.insert(ch.end(), v1.begin(), v1.end());
		ch.insert(ch.end(), v2.begin(), v2.end());
		sort(ch.begin(), ch.end());
		int mn = ch[0].first;
		pi nmn0(0x3f3f3f3f, 0), nmn1(0x3f3f3f3f, 0), nmn2(0x3f3f3f3f, 0);
		for (int i = 0; i < ch.size(); i++) {
			if (ch[i].first == mn) nmn0 = min(nmn0, ch[i]);
			else if (ch[i].first == mn + 1) nmn1 = min(nmn1, ch[i]);
			else if (ch[i].first == mn + 2) nmn2 = min(nmn1, ch[i]);
		}
		mn0 = nmn0, mn1 = nmn1, mn2 = nmn2;
	}
	printf("%d\n", mn0.first);
	return 0;
}