#include <bits/stdc++.h>
using namespace std;
map<int, int> del;
int a[100100];
int b[100100];
int ia[100100];
int ib[100100];
int minab(int a, int b) {
  if (a < 0) a = -a;
  if (b < 0) b = -b;
  return a <= b ? a : b;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    ia[a[i]] = i;
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &b[i]);
    ib[b[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    del[ib[i] - ia[i]]++;
  }
  for (int k = 0; k < n; k++) {
    map<int, int>::iterator it1, it2;
    it1 = del.lower_bound(k);
    if (it1 == del.end()) it1--;
    it2 = it1;
    if (it2 != del.begin()) it2--;
    int res = minab(it1->first - k, it2->first - k);
    printf("%d\n", res);
    if (k < n - 1) {
      int x = b[k];
      int iia = ia[x];
      int iib = ib[x];
      if (del[iib - iia] == 1) {
        del.erase(iib - iia);
      } else
        del[iib - iia]--;
      del[iib - iia + n]++;
    }
  }
}
