#include <bits/stdc++.h>
using namespace std;
int dis[200005], ar[200005];
bool vis[200005];
priority_queue<pair<int, int>, vector<pair<int, int> >,
               greater<pair<int, int> > >
    qu;
int main() {
  memset(dis, 127, sizeof(dis));
  int n;
  cin >> n;
  for (int i = 1; i < n + 1; i++) scanf("%d", &ar[i]);
  qu.push(make_pair(0, 1));
  pair<int, int> tmp;
  while (!qu.empty()) {
    tmp = qu.top();
    dis[tmp.second] = min(tmp.first, dis[tmp.second]);
    qu.pop();
    if (vis[tmp.second]) continue;
    vis[tmp.second] = 1;
    if (tmp.second - 1 > 0 && vis[tmp.second - 1] == 0)
      qu.push(make_pair(tmp.first + 1, tmp.second - 1));
    if (tmp.second + 1 <= n && vis[tmp.second + 1] == 0)
      qu.push(make_pair(tmp.first + 1, tmp.second + 1));
    if (vis[ar[tmp.second]] == 0)
      qu.push(make_pair(tmp.first + 1, ar[tmp.second]));
  }
  for (int i = 1; i < n + 1; i++) printf("%d%c", dis[i], " \n"[i == n]);
}
