#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e5 + 100;
int n, a[maxN], b[maxN], pos[maxN], res[maxN];
int ans[maxN];
struct cmp_min {
  bool operator()(int x, int y) {
    if (res[x] != res[y]) return res[x] < res[y];
    return x < y;
  }
};
struct cmp_max {
  bool operator()(int x, int y) {
    if (res[x] != res[y]) return res[x] > res[y];
    return x > y;
  }
};
set<int, cmp_min> h1;
set<int, cmp_max> h2;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%i", &a[i]);
  for (int i = 1; i <= n; i++) scanf("%i", &b[i]);
  for (int i = 1; i <= n; i++) pos[a[i]] = i;
  for (int i = 1; i <= n; i++) {
    res[b[i]] = pos[b[i]] - i;
    if (res[b[i]] >= 0)
      h1.insert(b[i]);
    else
      h2.insert(b[i]);
  }
  res[0] = 3e5;
  for (int i = n, j = 1, dem = 0; i > 0; i--, dem++, j--) {
    int t1, t2;
    if (!h1.empty())
      t1 = *h1.begin();
    else
      t1 = 0;
    if (!h2.empty())
      t2 = *h2.begin();
    else
      t2 = 0;
    if (j == 0) j = n;
    ans[j] = min(res[t1] - dem, abs(res[t2] - dem));
    while (res[*h1.begin()] == dem) {
      t1 = *h1.begin();
      res[t1] = dem;
      h1.erase(h1.begin());
      h2.insert(t1);
    }
    t2 = b[i];
    if (*h1.find(t2) == t2)
      h1.erase(t2);
    else
      h2.erase(t2);
    res[t2] = dem + pos[t2];
    h1.insert(t2);
  }
  a[n] = a[0];
  for (int i = 1; i <= n; i++) printf("%i\n", ans[i]);
  return 0;
}
