Vasya is pressing the keys on the keyboard reluctantly, squeezing out his ideas on the classical epos depicted in Homer's Odysseus... How can he explain to his literature teacher that he isn't going to become a writer? In fact, he is going to become a programmer. So, he would take great pleasure in writing a program, but none — in writing a composition.

As Vasya was fishing for a sentence in the dark pond of his imagination, he suddenly wondered: what is the least number of times he should push a key to shift the cursor from one position to another one?

Let's describe his question more formally: to type a text, Vasya is using the text editor. He has already written n lines, the i-th line contains ai characters (including spaces). If some line contains k characters, then this line overall contains (k + 1) positions where the cursor can stand: before some character or after all characters (at the end of the line). Thus, the cursor's position is determined by a pair of integers (r, c), where r is the number of the line and c is the cursor's position in the line (the positions are indexed starting from one from the beginning of the line).

Vasya doesn't use the mouse to move the cursor. He uses keys "Up", "Down", "Right" and "Left". When he pushes each of these keys, the cursor shifts in the needed direction. Let's assume that before the corresponding key is pressed, the cursor was located in the position (r, c), then Vasya pushed key:

  * "Up": if the cursor was located in the first line (r = 1), then it does not move. Otherwise, it moves to the previous line (with number r - 1), to the same position. At that, if the previous line was short, that is, the cursor couldn't occupy position c there, the cursor moves to the last position of the line with number r - 1;
  * "Down": if the cursor was located in the last line (r = n), then it does not move. Otherwise, it moves to the next line (with number r + 1), to the same position. At that, if the next line was short, that is, the cursor couldn't occupy position c there, the cursor moves to the last position of the line with number r + 1;
  * "Right": if the cursor can move to the right in this line (c < ar + 1), then it moves to the right (to position c + 1). Otherwise, it is located at the end of the line and doesn't move anywhere when Vasya presses the "Right" key;
  * "Left": if the cursor can move to the left in this line (c > 1), then it moves to the left (to position c - 1). Otherwise, it is located at the beginning of the line and doesn't move anywhere when Vasya presses the "Left" key.



You've got the number of lines in the text file and the number of characters, written in each line of this file. Find the least number of times Vasya should push the keys, described above, to shift the cursor from position (r1, c1) to position (r2, c2).

Input

The first line of the input contains an integer n (1 ≤ n ≤ 100) — the number of lines in the file. The second line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 105), separated by single spaces. The third line contains four integers r1, c1, r2, c2 (1 ≤ r1, r2 ≤ n, 1 ≤ c1 ≤ ar1 + 1, 1 ≤ c2 ≤ ar2 + 1).

Output

Print a single integer — the minimum number of times Vasya should push a key to move the cursor from position (r1, c1) to position (r2, c2).

Examples

Input

4
2 1 6 4
3 4 4 2


Output

3


Input

4
10 5 6 4
1 11 4 2


Output

6


Input

3
10 1 10
1 10 1 1


Output

3

Note

In the first sample the editor contains four lines. Let's represent the cursor's possible positions in the line as numbers. Letter s represents the cursor's initial position, letter t represents the last one. Then all possible positions of the cursor in the text editor are described by the following table.

123

12

123s567

1t345

One of the possible answers in the given sample is: "Left", "Down", "Left".
import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class Solver {
    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new FileReader("input.txt"));
        pw = new PrintWriter("output.txt");

//      br = new BufferedReader(new InputStreamReader(System.in));
//        pw = new PrintWriter(System.out);

        n = nextInt();

        a = new int[n];

        int max = 0;

        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
            max = max(a[i], max);
        }

        dist = new int[n][max + 1];

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < a[i] + 1; j++) {
                dist[i][j] = -1;
            }
        }

        int x1 = nextInt() - 1;
        int y1 = nextInt() - 1;
        int x2 = nextInt() - 1;
        int y2 = nextInt() - 1;

        dist[x1][y1] = 0;

        Queue<Point> q = new ArrayDeque<>();
        q.add(new Point(x1, y1));
        while (!q.isEmpty()) {
            Point v = q.poll();
            int x = v.x;
            int y = v.y;
            if (x - 1 >= 0) {
                if (a[x - 1] < y) {
                    if (dist[x - 1][a[x - 1]] == -1) {
                        dist[x - 1][a[x - 1]] = dist[x][y] + 1;
                        q.add(new Point(x - 1, a[x - 1]));
                    }
                }
                if (dist[x - 1][y] == -1) {
                    dist[x - 1][y] = dist[x][y] + 1;
                    q.add(new Point(x - 1, y));
                }
            }

            if (x + 1 < n) {
                if (a[x + 1] < y) {
                    if (dist[x + 1][a[x + 1]] == -1) {
                        dist[x + 1][a[x + 1]] = dist[x][y] + 1;
                        q.add(new Point(x + 1, a[x + 1]));
                    }
                }
                if (dist[x + 1][y] == -1) {
                    dist[x + 1][y] = dist[x][y] + 1;
                    q.add(new Point(x + 1, y));
                }
            }

            if (y - 1 >= 0) {
                if (dist[x][y - 1] == -1) {
                    dist[x][y - 1] = dist[x][y] + 1;
                    q.add(new Point(x, y - 1));
                }
            }

            if (y + 1 <= a[x]) {
                if (dist[x][y + 1] == -1) {
                    dist[x][y + 1] = dist[x][y] + 1;
                    q.add(new Point(x, y + 1));
                }
            }
//            for (int i = 0; i < n; i++) {
//                for (int j = 0; j < a[i] + 1; j++) {
//                    pw.print(dist[i][j] + " ");
//                }
//                pw.println();
//            }
//            pw.println();
        }
//        for (int i = 0; i < n; i++) {
//            for (int j = 0; j < max + 1; j++) {
//                pw.print(dist[i][j] + " ");
//            }
//            pw.println();
//        }
//        pw.println();
        pw.println(dist[x2][y2]);
        pw.close();
    }

    static int[] a;
    static int[][] dist;
    static int n;

    static StringTokenizer st = new StringTokenizer("");
    static BufferedReader br;
    static PrintWriter pw;

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }
}

class Point {
    int x, y;

    public Point(int x, int y) {
        this.x = x;
        this.y = y;
    }
}