#include <bits/stdc++.h>
int main(void) {
  int n;
  std::cin >> n;
  std::vector<std::vector<std::pair<int, int>>> g(n);
  for (int i = 1; i < n; ++i) {
    g[i - 1].push_back({i, 1});
    g[i].push_back({i - 1, 1});
  }
  for (int i = 0; i < n; ++i) {
    int cur;
    std::cin >> cur;
    g[i].push_back({cur - 1, 1});
  }
  std::vector<int> d(n, (int)1e9);
  std::set<std::pair<int, int>> q;
  d[0] = 0;
  q.insert({d[0], 0});
  while (!q.empty()) {
    int v = q.begin()->second;
    q.erase(q.begin());
    for (int i = 0; i < g[v].size(); ++i) {
      int to = g[v][i].first, len = g[v][i].second;
      if (d[v] + len < d[to]) {
        q.erase({d[to], to});
        d[to] = d[v] + len;
        q.insert({d[to], to});
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    std::cout << d[i] << ' ';
  }
  std::cout << std::endl;
  return 0;
}
