#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n), pa(n), pb(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    --a[i];
    pa[a[i]] = i;
  }
  for (int i = 0; i < n; ++i) {
    cin >> b[i];
    --b[i];
    pb[b[i]] = i;
  }
  vector<int> ans(n, 999999);
  vector<vector<int>> evi(n), evo(n);
  multiset<int> segs;
  for (int i = 0; i < n; ++i) {
    int wh = (pb[i] - pa[i] + n) % n;
    int tol = n - pa[i], tor = pa[i];
    evi[wh].push_back(wh);
    if ((wh + tor) % n < wh) {
      segs.insert(wh - n);
      evo[(wh + tor) % n].push_back(wh - n);
    } else {
      evo[(wh + tor) % n].push_back(wh);
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int z : evi[i]) {
      segs.insert(z);
    }
    if (segs.size()) {
      auto it = segs.end();
      --it;
      int x = *it;
      ans[i] = min(ans[i], (i - x) % n);
    }
    for (int z : evo[i]) {
      segs.erase(segs.find(z));
    }
  }
  segs.clear();
  evi.assign(n, vector<int>());
  evo.assign(n, vector<int>());
  for (int i = 0; i < n; ++i) {
    int wh = (pb[i] - pa[i] + n) % n;
    int tol = n - pa[i] - 1, tor = pa[i];
    evi[wh].push_back(wh);
    if ((wh - tol + n) % n > wh) {
      segs.insert(wh + n);
      evo[(wh - tol + n) % n].push_back(wh + n);
    } else {
      evo[(wh - tol + n) % n].push_back(wh);
    }
  }
  for (int i = n - 1; i >= 0; --i) {
    for (int z : evi[i]) {
      segs.insert(z);
    }
    if (segs.size()) {
      int x = *segs.begin();
      ans[i] = min(ans[i], (x - i) % n);
    }
    for (int z : evo[i]) {
      segs.erase(segs.find(z));
    }
  }
  for (int i = 0; i < n; ++i) {
    cout << ans[i] << endl;
  }
  return 0;
}
