#include <bits/stdc++.h>
using namespace std;
const int maxn = 3 * 1e5 + 100;
int dp[maxn];
int A[maxn];
queue<int> q;
int main() {
  int n;
  scanf("%d", &n);
  int i, j;
  for (i = 1; i <= n; i++) scanf("%d", &A[i]);
  memset(dp, -1, sizeof dp);
  dp[1] = 0;
  q.push(1);
  while (!q.empty()) {
    int tmp = q.front();
    q.pop();
    if (dp[A[tmp]] == -1) {
      dp[A[tmp]] = dp[tmp] + 1;
      q.push(A[tmp]);
    }
    for (i = -1; i < 2; i += 2)
      if (tmp + i >= 1 && tmp + i <= n && dp[tmp + i] == -1) {
        dp[tmp + i] = dp[tmp] + 1;
        q.push(tmp + i);
      }
  }
  printf("%d", dp[1]);
  for (i = 2; i <= n; i++) printf(" %d", dp[i]);
  return 0;
}
