#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
#define Seg_Max_N (1<<18) 

using Value = int;
const Value ini = -1e9;
struct segtree {
	int N;
	vector<Value>dat;

	segtree() {}
	segtree(int n) :dat(2 * Seg_Max_N) {
		N = 1;
		while (N < n) N *= 2;
		for (int i = 0; i < 2 * N - 1; i++) {
			dat[i] = ini;
		}
	}
	Value connect(const Value&l, const Value&r) {
		return max(l,r);
	}
	// update k th element
	void update(int k, Value a) {
		k += N - 1;
		dat[k] = a;

		while (k > 0) {
			k = (k - 1) / 2;
			const Value al(dat[k * 2 + 1]);
			const Value ar(dat[k * 2 + 2]);
			dat[k] = connect(al, ar);
		}
	}
	// min [a, b)
	Value  query(int a, int b) { return query(a, b, 0, 0, N); }
	Value  query(int a, int b, int k, int l, int r) {
		if (r <= a or b <= l) return ini;
		if (a <= l and r <= b) return dat[k];
		const int m = (l + r) / 2;
		const Value al(query(a, b, k * 2 + 1, l, m));
		const Value ar(query(a, b, k * 2 + 2, m, r));
		return connect(al, ar);
	}
};


int solve(vector<int>b) {
	int num = 0;
	int ans=0;
	int pre = -1;
	for (auto a : b) {
		if (a > pre) {
			num++;
			ans=max(ans,num);
			pre = a;
		}
		else if (a == pre) {

		}
		else {
			pre = a;
			num = 1;
		}
	}
	return ans;
}
template<typename T> struct Compress {
	map<T, int>mp;
	map<int, T>revmp;

	Compress(vector<T>vs) {
		setmp(vs);
	}

	Compress() :mp(), revmp() {

	}
	void setmp(vector<T>vs) {
		sort(vs.begin(), vs.end());
		vs.erase(unique(vs.begin(), vs.end()), vs.end());
		for (int i = 0; i < static_cast<int>(vs.size()); ++i) {
			mp[vs[i]] = i;
			revmp[i] = vs[i];
		}
	}
};
int main() {
	int N;cin>>N;
	vector<int>v(N);
	for (int i = 0; i < v.size(); ++i) {
		cin>>v[i];
	}
	Compress<int>comp(v);
	for (auto&a : v) {
		a=comp.mp[a];
	}
	int ans1=solve(v);

	for(auto&a:v){
		a=N-a;
	}
	int ans2=solve(v);
	cout<<max(ans1,ans2)<<endl;
	
	return 0;
} 