#include <bits/stdc++.h>
using namespace std;
priority_queue<pair<int, int> > q;
vector<vector<int> > v;
int n, dp[200001];
int main() {
  scanf("%d", &n);
  v.resize(n + 1);
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    if (i == 1)
      v[i].push_back(x), v[i].push_back(i + 1);
    else if (i == n)
      v[i].push_back(x), v[i].push_back(i - 1);
    else
      v[i].push_back(x), v[i].push_back(i + 1), v[i].push_back(i - 1);
  }
  memset(dp, -1, sizeof(dp));
  q.push(make_pair(0, 1));
  while (!q.empty()) {
    int x = q.top().second, y = q.top().first;
    q.pop();
    dp[x] = -y;
    for (int i = 0; i < v[x].size(); i++)
      if (dp[v[x][i]] == -1) q.push(make_pair(y - 1, v[x][i]));
    while (!q.empty() && dp[q.top().second] != -1) q.pop();
  }
  for (int i = 1; i <= n; i++) printf("%d ", dp[i]);
}
