program juosta;


type
 Tjuosta =
   record
     n : integer;
     data: array[1..100] of integer;
   end;
var
  f : text;
  jst : tjuosta;
  i, st, en : integer;
  mvs : integer;
  been : array[1..100] of boolean;

function newPos(st : integer): integer;
var
  prk : integer;
begin
  prk := jst.data[st];
  while prk < 0 do inc(prk, jst.n);
  st := (st + prk) mod jst.n;
  if st = 0 then st := jst.n;
  newPos := st;
end;

begin
  assign(f, 'JUOSTA.IN');
  reset(f);
  readln(f, jst.n);
  for i := 1 to jst.n do
  begin
    read(f, jst.data[i]);
    been[i] := false;
  end;
  readln(f);
  readln(f, st, en);
  close(f);  
  mvs := 0;
  while (not been[st]) and (st <> en) do
  begin
    been[st] := true;
    st := newPos(st);
    inc(mvs);
  end;

  assign(f, 'JUOSTA.OUT');
  rewrite(f);

  if been[st] then write(f, 0)
              else write(f, mvs);
  close(f);

end.
