There are n beautiful skyscrapers in New York, the height of the i-th one is h_i. Today some villains have set on fire first n - 1 of them, and now the only safety building is n-th skyscraper.

Let's call a jump from i-th skyscraper to j-th (i < j) discrete, if all skyscrapers between are strictly lower or higher than both of them. Formally, jump is discrete, if i < j and one of the following conditions satisfied: 

  * i + 1 = j 
  * max(h_{i + 1}, …, h_{j - 1}) < min(h_i, h_j) 
  * max(h_i, h_j) < min(h_{i + 1}, …, h_{j - 1}). 



At the moment, Vasya is staying on the first skyscraper and wants to live a little longer, so his goal is to reach n-th skyscraper with minimal count of discrete jumps. Help him with calcualting this number.

Input

The first line contains a single integer n (2 ≤ n ≤ 3 ⋅ 10^5) — total amount of skyscrapers.

The second line contains n integers h_1, h_2, …, h_n (1 ≤ h_i ≤ 10^9) — heights of skyscrapers.

Output

Print single number k — minimal amount of discrete jumps. We can show that an answer always exists.

Examples

Input


5
1 3 1 4 5


Output


3

Input


4
4 2 2 4


Output


1

Input


2
1 1


Output


1

Input


5
100 1 100 1 100


Output


2

Note

In the first testcase, Vasya can jump in the following way: 1 → 2 → 4 → 5.

In the second and third testcases, we can reach last skyscraper in one jump.

Sequence of jumps in the fourth testcase: 1 → 3 → 5.
import java.util.*;
import java.io.*;
 
public class Main2 {
	static class FastReader{ BufferedReader br;StringTokenizer st;public FastReader(){br = new BufferedReader(new InputStreamReader(System.in));}String next(){while (st == null || !st.hasMoreElements()){try{st = new StringTokenizer(br.readLine());}catch (IOException  e){e.printStackTrace();}}return st.nextToken();}int nextInt(){ return Integer.parseInt(next());}long nextLong(){return Long.parseLong(next());}double nextDouble(){return Double.parseDouble(next());}String nextLine(){String str = ""; try{str = br.readLine(); } catch (IOException e) {e.printStackTrace();} return str; }}
	static long mod = (long)(1e9+7);
//	static long mod = 998244353;
//	static Scanner sc = new Scanner(System.in);
	static FastReader sc = new FastReader();
	static PrintWriter out = new PrintWriter(System.out);
	public static void main (String[] args) {
		int t = 1;
//    	t = sc.nextInt();
	    z : for(int tc=1;tc<=t;tc++) {
	    	Stack<Integer> st = new Stack<>();
	    	int n = sc.nextInt();
	    	int rh[] = new int[n+1];
	    	int rl[] = new int[n+1];
	    	int lh[] = new int[n+1];
	    	int ll[] = new int[n+1];
	    	int a[] = new int[n+1];
	    	for(int i=1;i<=n;i++) a[i] = sc.nextInt();
	    	for(int i=1;i<=n;i++) {
	    		while(!st.isEmpty() && a[st.peek()]>a[i]) st.pop();
	    		if(st.isEmpty()) ll[i] = -1;
	    		else ll[i] = st.peek();
	    		st.add(i);
	    	}
	    	st.clear();
	    	for(int i=1;i<=n;i++) {
	    		while(!st.isEmpty() && a[st.peek()]<a[i]) st.pop();
	    		if(st.isEmpty()) lh[i] = -1;
	    		else lh[i] = st.peek();
	    		st.add(i);
	    	}
	    	st.clear();
	    	for(int i=n;i>=1;i--) {
	    		while(!st.isEmpty() && a[st.peek()]<a[i]) st.pop();
	    		if(st.isEmpty()) rh[i] = -1;
	    		else rh[i] = st.peek();
	    		st.add(i);
	    	}
	    	st.clear();
	    	for(int i=n;i>=1;i--) {
	    		while(!st.isEmpty() && a[st.peek()]>a[i]) st.pop();
	    		if(st.isEmpty()) rl[i] = -1;
	    		else rl[i] = st.peek();
	    		st.add(i);
	    	}
	    	List<Integer> temp[] = new ArrayList[n+1];
	    	for(int i=1;i<=n;i++) temp[i] = new ArrayList<>();
	    	for(int i=1;i<=n;i++) {
	    		if(ll[i]!=-1) temp[i].add(ll[i]);
	    		if(lh[i]!=-1) temp[i].add(lh[i]);
	    		if(rl[i]!=-1) temp[rl[i]].add(i);
	    		if(rh[i]!=-1) temp[rh[i]].add(i);
	    	}
	    	int dp[] = new int[n+1];
	    	dp[1] = 0;
	    	for(int i=2;i<=n;i++) {
	    		dp[i] = Integer.MAX_VALUE;
	    		for(int val : temp[i]) {
	    			dp[i] = Math.min(dp[i], 1 + dp[val]);
	    		}
	    	}
	    	out.write(dp[n]+"\n");
	    }
		out.close();
	}
	static int gcd(int a,int b) { if(b==0) return a; return gcd(b,a%b); }
	private static void sort(int[] a) {List<Integer> k = new ArrayList<>();for(int val : a) k.add(val);Collections.sort(k);for(int i=0;i<a.length;i++) a[i] = k.get(i);}
	private static void ini(List<Integer>[] tre2){for(int i=0;i<tre2.length;i++){tre2[i] = new ArrayList<>();}}
	private static void init(List<int[]>[] tre2){for(int i=0;i<tre2.length;i++){tre2[i] = new ArrayList<>();}}
	private static void sort(long[] a) {List<Long> k = new ArrayList<>();for(long val : a) k.add(val);Collections.sort(k);for(int i=0;i<a.length;i++) a[i] = k.get(i);}
}