
#include <algorithm>
#include <cstdint>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <limits>
#include <ostream>
#include <sstream>
#include <string>
#include <sys/types.h>
#include <vector>

std::vector<int> read_input() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);

  std::string line = std::string{};
  std::getline(std::cin, line);
  std::getline(std::cin, line);
  std::istringstream iss = std::istringstream{line};

  return std::vector<int>{std::istream_iterator<int>{iss},
                          std::istream_iterator<int>{}};
}
int main(int argc, char *argv[]) {
  std::vector<int> input = read_input();
  if (input.size() < 2) {
    std::printf("0");
    return 0;
  }

  for (int i = 0; i < static_cast<int>(input.size()); i++) {
    input[i] = input[i] - i;
  }

  int current_max = std::numeric_limits<int>::min();
  for (size_t i = 1; i < input.size(); i++) {
    auto iter_delim = input.cbegin() + i;
    int max_end_stub = *std::max_element(iter_delim, input.cend());
    int min_start_stub = *std::min_element(input.cbegin(), iter_delim);
    int difference = max_end_stub - min_start_stub;
    current_max = std::max(difference, current_max);
  }

  std::printf("%d", current_max);

  return 0;
}
