#include <bits/stdc++.h>
using namespace std;
template <typename T>
void printarr(T *A, int n) {
  for (int i = 0; i < n; i++) {
    cout << A[i] << " ";
  }
  cout << "\n";
}
template <typename T>
void printcont(T A) {
  for (auto a : A) {
    cout << a << " ";
  }
  cout << "\n";
}
template <typename T>
void arrinit(T *A, int n, T data) {
  for (int i = 0; i < n; i++) {
    A[i] = data;
  }
}
template <typename T>
void takeinput(T *A, int n) {
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }
}
template <typename T>
T gcd(T a, T b) {
  if (a == 0) return b;
  if (b == 0) return a;
  if (a > b) return gcd(b, a % b);
  return gcd(b % a, a);
}
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<vector<int>> g(n);
  for (int i = 0; i < n - 1; i++) {
    g[i].push_back(i + 1);
    g[i].push_back(a[i] - 1);
    g[i + 1].push_back(i);
  }
  vector<bool> v(n, false);
  vector<long long> dist(n, 1e10);
  dist[0] = 0;
  queue<int> q;
  q.push(0);
  v[0] = true;
  while (!q.empty()) {
    int curr = q.front();
    q.pop();
    v[curr] = true;
    for (int i = 0; i < g[curr].size(); i++) {
      if (!v[g[curr][i]]) {
        v[g[curr][i]] = true;
        q.push(g[curr][i]);
        dist[g[curr][i]] = min(dist[g[curr][i]], dist[curr] + 1);
      }
    }
  }
  printcont(dist);
}
int main() {
  {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  }
  long long t = 1;
  for (int i = 0; i < t; i++) {
    solve();
  }
  return 0;
}
