#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
multiset<int> l, r;
int a[maxn], b[maxn], posa[maxn], posb[maxn];
int n;
int main() {
  while (scanf("%d", &n) != EOF) {
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      posa[a[i]] = i;
    }
    for (int i = 1; i <= n; i++) {
      scanf("%d", &b[i]);
      posb[b[i]] = i;
    }
    l.clear();
    r.clear();
    int Min = 1 << 30;
    for (int i = 1; i <= n; i++) {
      if (posb[i] > posa[i]) {
        r.insert(posb[i] - posa[i]);
        Min = min(Min, posb[i] - posa[i]);
      } else {
        l.insert(posa[i] - posb[i]);
        Min = min(Min, posa[i] - posb[i]);
      }
    }
    printf("%d\n", Min);
    for (int i = 2; i <= n; i++) {
      l.erase(l.find(posa[b[i - 1]] - (i - 1)));
      r.insert(n - posa[b[i - 1]] + (i - 1));
      while (r.size() > 0 && *r.begin() - (i - 1) == 0) {
        r.erase(r.begin());
        l.insert(-i + 1);
      }
      Min =
          min(*l.begin() + i - 1, r.size() > 0 ? *r.begin() - (i - 1) : n + 1);
      printf("%d\n", Min);
    }
  }
  return 0;
}
