#define DEBUG 0

#include <bits/stdc++.h>
using namespace std;

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------

struct inter { int l,r,v; };
int A[200000];
vector<inter> dp,dp2;
vpii events;
vector<inter> com(vector<inter> v) {
    int i;
    events.clear();
    for (i = 0; i < v.size(); i++) events.pb(mp(v[i].l,v[i].v)),events.pb(mp(v[i].r+1,-50-v[i].v));
    sort(events.begin(),events.end());
    vector<inter> v2;
    multiset<int> S;
    for (i = 0; i < events.size()-1; i++) {
        if (events[i].second >= 0) S.insert(events[i].second);
        else S.erase(S.find(-50-events[i].second));
        if (events[i+1].first > events[i].first) {
            if (!v2.empty() && (v2.back().v == *S.begin())) v2.back().r = events[i+1].first-1;
            else v2.pb((inter){events[i].first,events[i+1].first-1,*S.begin()});
        }
    }
    return v2;
}
int main() {
    int i;
    int N;
    scanf("%d",&N);
    for (i = 0; i < N; i++) scanf("%d",&A[i]);

    int j;
    int ans1 = 1,ans2 = 1;
    for (i = 0; i < N-1; i++) {
        if (A[i] > A[i+1]) ans1++;
        if (A[i] < A[i+1]) ans2++;
    }
    int ans = min(ans1,ans2);
    dp.pb((inter){0,A[0]-1,1}),dp.pb((inter){A[0],A[0],0});
    for (i = 1; i < N; i++) {
        int diff = A[i-1]-A[i];
        for (j = 0; j < dp.size(); j++) {
            int x = 0,y = -diff;
            if (x < y) swap(x,y);
            if (dp[j].l+x <= A[i]) dp2.pb((inter){dp[j].l+x,A[i],dp[j].v});
            if (max(dp[j].l+y,0) <= A[i]) dp2.pb((inter){max(dp[j].l+y,0),A[i],dp[j].v+1});
            dp2.pb((inter){0,A[i],dp[j].v+2});
        }
        dp = com(dp2);
        dp2.clear();
    }
    int c = 1e9;
    for (i = 0; i < dp.size(); i++) {
        if (dp[i].l > 0) c = min(c,dp[i].v+1);
        else c = min(c,dp[i].v);
    }
    cout << min(ans,c) << endl;

    return 0;
}



Measured memory_bytes: 1024