#include <bits/stdc++.h>
using namespace std;
int minEnergy[200000];
int shortcut[200000];
int main() {
  int n;
  scanf("%d", &n);
  for (size_t i = 0; i < n; i++) {
    minEnergy[i] = 10000000;
    int tmp;
    scanf("%d", &tmp);
    shortcut[i] = tmp - 1;
  }
  minEnergy[0] = 0;
  queue<int> workQ;
  workQ.push(0);
  while (!workQ.empty()) {
    int pos = workQ.front();
    workQ.pop();
    if (pos - 1 >= 0 && minEnergy[pos - 1] > minEnergy[pos] + 1) {
      minEnergy[pos - 1] = minEnergy[pos] + 1;
      workQ.push(pos - 1);
    }
    if (pos + 1 < n && minEnergy[pos + 1] > minEnergy[pos] + 1) {
      minEnergy[pos + 1] = minEnergy[pos] + 1;
      workQ.push(pos + 1);
    }
    if (minEnergy[shortcut[pos]] > minEnergy[pos] + 1) {
      minEnergy[shortcut[pos]] = minEnergy[pos] + 1;
      workQ.push(shortcut[pos]);
    }
  }
  for (size_t i = 0; i < n; i++) {
    printf("%d ", minEnergy[i]);
  }
  return 0;
}
