#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using std::bitset;
using namespace std;
int a[101000], pa[101000], b[101000], push_back[101000];
multiset<int> S;
multiset<int>::iterator it;
int n, ans;
int main() {
  int i, j, tem, v;
  while (scanf("%d", &n) != EOF) {
    for (i = 1; i <= n; i++) {
      scanf("%d", a + i);
      pa[a[i]] = i;
    }
    for (i = 1; i <= n; i++) {
      scanf("%d", b + i);
      push_back[b[i]] = i;
    }
    S.clear();
    for (i = 1; i <= n; i++) {
      tem = i - push_back[a[i]];
      S.insert(tem);
    }
    for (i = 0; i < n; i++) {
      it = S.lower_bound(-i);
      if (it != S.begin()) it--;
      ans = 0x3f3f3f3f;
      for (j = 1; j <= 2; j++) {
        ans = min(ans, (((*it + i) > 0) ? (*it + i) : -(*it + i)));
        if (it != S.end()) it++;
      }
      printf("%d\n", ans);
      tem = pa[b[i + 1]];
      v = tem - (i + 1);
      it = S.lower_bound(v);
      S.erase(it);
      v = v - n;
      S.insert(v);
    }
  }
  return 0;
}
