#include <bits/stdc++.h>
using namespace std;
const int maxn = 10008, maxm = 100008;
struct Tedge {
  int tot, start[maxn];
  struct arr {
    int a, next;
  } e[maxm];
  void Clear() {
    tot = 1;
    memset(start, 0, sizeof(start));
  }
  void Add(int x, int y) {
    e[++tot].a = y;
    e[tot].next = start[x];
    start[x] = tot;
    e[++tot].a = x;
    e[tot].next = start[y];
    start[y] = tot;
  }
} E;
int n;
int a[100008], p[100008], b[100008];
struct arr {
  int v, i;
  arr(int v1, int i1) {
    v = v1;
    i = i1;
  }
  bool operator<(const arr &t) const { return v > t.v; }
};
priority_queue<arr> Q1, Q2;
struct Tprogram {
  void Init() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      p[a[i]] = i;
    }
    for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
    for (int i = 1; i <= n; i++)
      if (i <= p[b[i]]) {
        Q1.push(arr(p[b[i]] - i, i));
      } else
        Q2.push(arr(i - p[b[i]], i));
  }
  void Work() {
    int ans;
    for (int i = 0; i <= n - 1; i++) {
      if (i) Q2.push(arr(n - p[b[i]] + i, n));
      while (!Q1.empty() && Q1.top().i <= i) Q1.pop();
      if (Q1.empty())
        ans = Q2.top().v - i;
      else if (Q2.empty())
        ans = Q1.top().v + i;
      else
        ans =
            (Q1.top().v + i < Q2.top().v - i ? Q1.top().v + i : Q2.top().v - i);
      printf("%d\n", ans);
      if (i == n - 1) continue;
      while (!Q2.empty() && Q2.top().v - i == 0)
        Q1.push(arr(-i, Q2.top().i)), Q2.pop();
    }
  }
} program;
int main() {
  program.Init();
  program.Work();
  return 0;
}
