#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
void solve() {
  int n;
  cin >> n;
  vector<int> A(n + 1), D(n + 1);
  for (int i = (1); (1) > 0 ? i < (n + 1) : i > (n + 1); i += (1)) cin >> A[i];
  queue<int> q;
  q.push(1);
  D[1] = 1;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    if (!D[A[u]]) {
      D[A[u]] = D[u] + 1;
      q.push(A[u]);
    }
    if (u > 1 && !D[u - 1]) {
      D[u - 1] = D[u] + 1;
      q.push(u - 1);
    }
    if (u < n && !D[u + 1]) {
      D[u + 1] = D[u] + 1;
      q.push(u + 1);
    }
  }
  for (int i = (1); (1) > 0 ? i < (n + 1) : i > (n + 1); i += (1))
    cout << (D[i] - 1) << " ";
  cout << endl;
}
int main() { solve(); }
