#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > adj[200000 + 5];
int dist[200000 + 5];
void dij(int s) {
  dist[s] = 0;
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      pq;
  pq.push(pair<int, int>(0, s));
  while (!pq.empty()) {
    int w = pq.top().first;
    int u = pq.top().second;
    pq.pop();
    if (w > dist[u]) continue;
    for (int i = int(0); i < (int)adj[u].size(); ++i) {
      int v = adj[u][i].second;
      int nw = adj[u][i].first;
      if (dist[u] + nw < dist[v]) {
        dist[v] = dist[u] + nw;
        pq.push(pair<int, int>(dist[v], v));
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = int(1); i < (int)n + 1; ++i) {
    int a;
    cin >> a;
    adj[i].push_back(pair<int, int>(1, a));
    if (i > 1) adj[i].push_back(pair<int, int>(1, i - 1));
    if (i < n) adj[i].push_back(pair<int, int>(1, i + 1));
  }
  memset(dist, 0x7F, sizeof dist);
  dij(1);
  for (int i = int(1); i < (int)n + 1; ++i) {
    if (i > 1) cout << " ";
    cout << dist[i];
  }
  cout << endl;
  return 0;
}
