#include <bits/stdc++.h>
using namespace std;
vector<int> solve(const vector<int> &a) {
  vector<int> d(a.size(), 0);
  for (int i = 0; i < a.size(); ++i) d[i] = i;
  vector<bool> visited(a.size(), false);
  queue<int> q;
  q.push(0);
  visited[0] = true;
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    if (v - 1 > 0 && !visited[v - 1]) {
      visited[v - 1] = true;
      d[v - 1] = d[v] + 1;
      q.push(v - 1);
    }
    if (v + 1 < a.size() && !visited[v + 1]) {
      visited[v + 1] = true;
      d[v + 1] = d[v] + 1;
      q.push(v + 1);
    }
    if (!visited[a[v]]) {
      visited[a[v]] = true;
      d[a[v]] = d[v] + 1;
      q.push(a[v]);
    }
  }
  return d;
}
int main() {
  int n;
  cin >> n;
  vector<int> a(n, 0);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    --a[i];
  }
  vector<int> d = solve(a);
  for (auto di : d) {
    cout << di << " ";
  }
  return 0;
}
