"use strict";

function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }

function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }

function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }

function _toArray(arr) { return _arrayWithHoles(arr) || _iterableToArray(arr) || _nonIterableRest(); }

function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }

function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }

function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }

var main = function main(input) {
  var _input$split = input.split(/\s/),
      _input$split2 = _toArray(_input$split),
      n = _input$split2[0],
      a = _input$split2.slice(1);

  var max = 0;
  var strArray = Array.from({
    length: a[0]
  }, function () {
    return 0;
  });

  for (var i = 1; i < n; i++) {
    if (Number(a[i - 1]) < Number(a[i])) {
      strArray.push.apply(strArray, _toConsumableArray(Array.from({
        length: a[i] - a[i - 1]
      }, function () {
        return 0;
      })));
    } else {
      strArray.length = a[i];
      var noChange = true;

      for (var j = strArray.length - 1; 0 <= j; j--) {
        if (strArray[j] < max) {
          noChange = false;
          strArray[j]++;
          break;
        }
      }

      if (noChange) {
        max++;
        strArray[strArray.length - 1] = max;
      }
    }
  }

  console.log(max + 1);
};

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