#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int a[N], b[N], posa[N], posb[N];
set<pair<int, int> > pd, nd;
int main() {
  int n, i;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", a + i);
    posa[a[i]] = i;
  }
  for (i = 1; i <= n; i++) {
    scanf("%d", b + i);
    posb[b[i]] = i;
  }
  for (i = 1; i <= n; i++) {
    int diff = abs(posb[i] - posa[i]);
    if (posb[i] >= posa[i])
      pd.insert({diff, i});
    else
      nd.insert({diff, i});
  }
  for (i = 0; i < n; i++) {
    while (pd.size() > 0 && pd.begin()->first < i) {
      nd.insert({1 - i, pd.begin()->second});
      pd.erase(pd.begin());
    }
    if (i > 0) {
      int x = b[i];
      if (posb[x] < posa[x])
        nd.erase({posa[x] - posb[x], x});
      else
        nd.erase({1 - (posb[x] - posa[x] + 1), x});
      pd.insert({n - posa[x] + i, x});
    }
    printf("%d\n", min(pd.begin()->first - i, nd.begin()->first + i));
  }
}
