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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int N;
    cin>>N;
    vint A;
    rep(i,N){
        int a;cin>>a;
        if(A.size()==0||A.back()!=a)A.pb(a);
    }

    int ans=1;
    int cur=0;
    while(cur+1<A.size()){
        int nex=cur+1;
        while(nex+1<A.size()&&(A[nex+1]-A[nex])*(A[cur+1]-A[cur])>0)nex++;
        chmax(ans,nex-cur+1);
        cur=nex;
    }
    cout<<ans<<endl;
    return 0;
}