var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var n = o.a();
  var a = o.l();
  var ok = n, ng = 0;
  while(1 < ok - ng){
    var mid = ok + ng >> 1;
    var f = 1, l = 0, b = new Map();
    for(var i = 0; i < n; i++){
      if(l < a[i]){
        l = a[i];
      }else{
        if(mid === 1){f = 0; break;}
        for(var k of b)if(k > l)b.delete(k);
        var u = l = a[i];
        while(b.has(u) && b.get(u) === mid-1 && 0 < u)b.set(u--,0);
        if(u === 0){f = 0; break;}
        if(b.has(u))b.set(u,b.get(u)+1);
        else b.set(u,1);
      }
    }
    if(f)ok = mid; else ng = mid;
  }
  return ok;
}