#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& _p) {
  return os << "(" << _p.first << "," << _p.second << ")";
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& _V) {
  bool f = true;
  os << "[";
  for (auto v : _V) {
    os << (f ? "" : ",") << v;
    f = false;
  }
  return os << "]";
}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& _S) {
  bool f = true;
  os << "(";
  for (auto s : _S) {
    os << (f ? "" : ",") << s;
    f = false;
  }
  return os << ")";
}
template <typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& _M) {
  return os << set<pair<T, U>>(_M.begin(), _M.end());
}
template <class TH>
void _dbg(const char* sdbg, TH h) {
  cerr << sdbg << '=' << h << endl;
}
template <class TH, class... TA>
void _dbg(const char* sdbg, TH h, TA... a) {
  while (*sdbg != ',') cerr << *sdbg++;
  cerr << '=' << h << ", ";
  _dbg(sdbg + 1, a...);
}
const int mx = 200005;
int n;
int t[mx], res[mx];
vector<int> G[mx];
int main() {
  scanf("%d", &n);
  for (int(i) = (1); (i) <= (n); ++(i)) scanf("%d", &t[i]);
  for (int(i) = (1); (i) <= (n); ++(i)) {
    res[i] = 1e9 + 7;
    if (i != 1) G[i].push_back(i - 1);
    if (i != n) G[i].push_back(i + 1);
    G[i].push_back(t[i]);
  }
  queue<pair<int, int>> q;
  res[1] = 0;
  q.push(make_pair(0, 1));
  while (!q.empty()) {
    pair<int, int> v = q.front();
    q.pop();
    if (v.first > res[v.second]) continue;
    for (int i = 0; i < G[v.second].size(); i++) {
      int u = G[v.second][i];
      if (res[u] > v.first + 1) {
        res[u] = v.first + 1;
        q.push(make_pair(res[u], u));
      }
    }
  }
  for (int(i) = (1); (i) <= (n); ++(i)) printf("%d ", res[i]);
}
