#include <bits/stdc++.h>
long long INF = 1e9 + 7;
long double eps = 1e-9;
using namespace std;
bool comp(int a, int b) { return a > b; }
class compare {
 public:
  template <class T>
  bool operator()(T a, T b) {
    return comp(a, b);
  }
};
char *string_to_char(string temp) {
  char *ans = new char[temp.length() + 1];
  strcpy(ans, temp.c_str());
  return ans;
}
long long max_string_length = 1024;
string spget() {
  char temp[max_string_length];
  gets(temp);
  string ans = temp;
  return ans;
}
void spget(string &ans) {
  char temp[max_string_length];
  gets(temp);
  ans = temp;
}
string ssget() {
  char temp[max_string_length];
  scanf("%s", &temp);
  string ans = temp;
  return ans;
}
void ssget(string &ans) {
  char temp[max_string_length];
  scanf("%s", &temp);
  ans = temp;
}
void ssput(string temp) {
  char *ttmp = string_to_char(temp);
  printf("%s", ttmp);
}
unsigned long long gcd(unsigned long long a, unsigned long long b) {
  if (a < b) swap(a, b);
  long long t = a * b;
  while (b > 0) {
    a %= b;
    if (a < b) swap(a, b);
  }
  t /= a;
  return a;
}
int main() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  vector<long long> ans(n + 1, INF);
  for (int i = 0; i < n; i++) {
    scanf("%I64d", &a[i]);
    a[i]--;
  }
  queue<long long> q1, q2;
  ans[0] = 0;
  q1.push(0);
  long long gg = 0;
  while (q1.size() > 0) {
    long long temp = q1.front();
    q1.pop();
    if (ans[temp] == gg) {
      if (temp + 1 < n && ans[temp + 1] > gg + 1) {
        q2.push(temp + 1);
        ans[temp + 1] = ans[temp] + 1;
      }
      if (temp - 1 >= 0 && ans[temp - 1] > gg + 1) {
        q2.push(temp - 1);
        ans[temp - 1] = ans[temp] + 1;
      }
      if (ans[a[temp]] > gg + 1) {
        q2.push(a[temp]);
        ans[a[temp]] = ans[temp] + 1;
      }
    }
    if (q1.empty()) {
      swap(q1, q2);
      gg++;
    }
  }
  for (long long i = 0; i < n; i++) printf("%I64d ", ans[i]);
  return 0;
}
