function Main(input) {
  var tmp = input.trim().split("\n");
  var limitAry = tmp.slice(1).map(val => parseInt(val, 10));
  var person = parseInt(tmp[0], 10);
  var goalNum = 0;
  var cnt = 0;
  var locationAry = [person];
  while (locationAry[5] !== person) {
    var num = locationAry.length;
    for (var i = 0; i < num; i++) {
      var moveNum = locationAry[i] < limitAry[i] ? locationAry[i] : limitAry[i];
      locationAry[i] -= moveNum;
      if (!locationAry[i + 1]) locationAry[i + 1] = 0;
      locationAry[i + 1] += moveNum;
    }
    cnt++;
  }
  console.log(cnt);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
