#include <bits/stdc++.h>
using namespace std;
long long MOD = 1e9 + 7;
long long INF = LLONG_MAX;
vector<string> &split(const std::string &s, char delim, vector<string> &e) {
  stringstream ss(s);
  string item;
  while (getline(ss, item, delim)) e.push_back(item);
  return e;
}
long long Pow(long long a, int b, int Mo) {
  long long ans = 1;
  for (; b; b >>= 1, a = a * a % Mo)
    if (b & 1) ans = ans * a % Mo;
  return ans;
}
long solve() { return 0; }
int main(int argc, char const *argv[]) {
  std::ios::sync_with_stdio(false);
  long long N;
  cin >> N;
  std::vector<std::vector<pair<long long, long long> > > G(N);
  for (long long i = 0; i < N; ++i) {
    long long x;
    cin >> x;
    x--;
    G[i].push_back(make_pair(x, 1LL));
    if (i < N - 1) G[i].push_back(make_pair(i + 1, 1LL));
    if (i > 0) G[i].push_back(make_pair(i - 1, 1LL));
  }
  std::vector<long long> D(N, INF);
  D[0] = 0;
  priority_queue<pair<long long, long long>,
                 vector<pair<long long, long long> >,
                 greater<pair<long long, long long> > >
      pq;
  std::vector<bool> flag(N, false);
  pq.push(make_pair(0, 0));
  while (!pq.empty()) {
    pair<long long, long long> T = pq.top();
    long long me = T.second;
    long long d = T.first;
    pq.pop();
    for (long long i = 0; i < G[me].size(); ++i)
      if (!flag[G[me][i].first]) {
        long long o = G[me][i].first;
        if (D[o] > D[me] + G[me][i].second) {
          D[o] = D[me] + G[me][i].second;
          pq.push(make_pair(D[o], o));
        }
      }
    flag[me] = true;
  }
  for (long long i = 0; i < N; ++i) {
    cout << D[i] << ' ';
    cout.flush();
    assert(D[i] != INF);
  }
  return 0;
}
