function Main(input) {
  var args = input.split("\n").filter(f => !!f).map(arg => parseInt(arg));
  var current = args.shift();
  var currentMod = current;
  var last = 1;
  var sum = 0;
  args.forEach(arg => {
    last = calc(current, currentMod, arg, last);
    sum += last;
    currentMod = current % arg;
    currentMod = currentMod === 0 ? arg : currentMod;
    current = arg;
    console.log(`sum: ${sum}`);
  });
  console.log(sum);
}

function calc(current, currentMod, arg, last) {
  var num = currentMod;
  if (arg < current) {
    console.log(`num: ${num}, (current - arg): ${(current - arg)}, (last - 1): ${(last - 1)}`);
    num += (current - arg) * (last - 1);
  }
  console.log(`num: ${num}`);
  return Math.ceil(num / arg);
}


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