import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;

void main() {
    int M = readln.chomp.to!int;
    int[] a = readln.split.to!(int[]);
    int[] b = a.dup.sort.uniq.array;
    int[] input = readln.split.to!(int[]);
    int s = input[0]-1;
    int g = input[1]-1;
    int[] N = readln.split.to!(int[]);

    int[][][] m = new int[][][](M, M, 2);
    foreach(ref e1; m) foreach(ref e2; e1) e2[] = -1;
    foreach(i; 0..M) {
        foreach(e; b) {
            int j = i+e;
            if (0<=j && j<M) {
                int k = j+N[j];
                if (0<=k && k<M) {
                    m[k][i][0] = e;
                    m[k][i][1] = 1;
                }
            }
            j = i-e;
            if (0<=j && j<M) {
                int k = j+N[j];
                if (0<=k && k<M) {
                    m[k][i][0] = e;
                    m[k][i][1] = -1;
                }
            }
        }
    }

    bool[] flg = new bool[M];
    flg[g] = true;
    auto list = DList!(Obj)(Obj(g));

    Obj obj;
    while(!list.empty) {
        Obj o = list.front;
        list.removeFront;
        foreach(i, e; m[o.now]) {
            if (e[0]>0 && !flg[i]) {
                flg[i] = true;
                Obj _o = Obj(i, o.ary~e);
                if (i == s) {
                    obj = _o;
                    list.clear;
                    break;
                }
                list.insertBack(_o);
            }
        }
    }

    while (!obj.ary.empty) {
        int t = a[readln.chomp.to!int-1];
        if (obj.ary.back[0] != t) {
            writeln(0);
        } else {
            writeln(obj.ary.back[1]);
            obj.ary = obj.ary[0..$-1];
        }
    }
}
struct Obj {
    int now;
    int[][] ary;
    this(int now, int[][] ary = []) {
        this.now = now;
        this.ary = ary;
    }
}