#include <bits/stdc++.h>
using namespace std;
using namespace chrono;
long long int advceil(long long int num, long long int den) {
  return (num % den == 0 ? num / den : num / den + 1);
}
long long int lstbt(long long int val) {
  long long int msk = val & (val - 1);
  return log2(val ^ msk);
}
map<long long int, set<long long int> > edges;
void solve() {
  long long int n;
  cin >> n;
  long long int arr[300001];
  for (long long int i = 1; i <= n - 1; i++)
    edges[i].insert(i + 1), edges[i + 1].insert(i);
  for (long long int i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  long long int dp[300001] = {};
  for (long long int i = 1; i <= n; i++) dp[i] = 1999999996000000010;
  set<pair<long long int, long long int> > s;
  s.insert(make_pair(0, 1));
  dp[1] = 0;
  while (!s.empty()) {
    pair<long long int, long long int> node = (*s.begin());
    s.erase(s.begin());
    for (auto itr : edges[node.second]) {
      long long int nextdist = dp[node.second] + abs(itr - node.second);
      if (dp[itr] > nextdist) {
        s.erase(make_pair(dp[itr], itr));
        dp[itr] = nextdist;
        s.insert(make_pair(nextdist, itr));
      }
    }
    if (dp[node.second] + 1 < dp[arr[node.second]]) {
      s.erase(make_pair(dp[arr[node.second]], arr[node.second]));
      dp[arr[node.second]] = dp[node.second] + 1;
      s.insert(make_pair(dp[node.second] + 1, arr[node.second]));
    }
  }
  for (long long int i = 1; i <= n; i++) cout << dp[i] << " ";
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  auto start1 = high_resolution_clock::now();
  solve();
  auto stop1 = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop1 - start1);
}
