#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int MAX = 200005;
vector<int> g[MAX];
int arr[MAX];
int dp[MAX];
bool v[MAX];
void bfs(int st) {
  v[st] = true;
  queue<int> q;
  q.push(st);
  while (!q.empty()) {
    int q1 = q.front();
    q.pop();
    for (int i : g[q1]) {
      dp[i] = min(dp[i], dp[q1] + 1);
      if (!v[i]) {
        v[i] = true;
        q.push(i);
      }
    }
  }
}
int main() {
  int x;
  scanf("%d", &x);
  for (int i = 0; i < x; i++) {
    cin >> arr[i];
    g[i + 1].push_back(arr[i]);
    if (i != x - 1) {
      g[i + 1].push_back(i + 2);
      g[i + 2].push_back(i + 1);
    }
  }
  for (int i = 1; i < x + 1; i++) {
    dp[i] = MOD;
  }
  dp[1] = 0;
  for (int i = 1; i < x + 1; i++) {
    if (!v[i]) {
      bfs(i);
    }
  }
  for (int i = 1; i < x + 1; i++) {
    cout << dp[i] << " ";
  }
}
