#include <bits/stdc++.h>
using namespace std;
int n;
int a[100005], b[100005], aa[100005];
int sol[100005];
int mxd[100005], mxu[100005];
int st[100005][3];
int sti;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    aa[a[i]] = i;
  }
  for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
  for (int i = 1; i <= n; i++) sol[i] = 1000000;
  for (int i = 1; i <= n; i++) mxd[i] = 0;
  for (int i = 1; i <= n; i++) mxu[i] = 0;
  for (int i = 1; i <= n; i++) {
    int t;
    if (i >= aa[b[i]]) {
      t = i - aa[b[i]] + 1;
    } else {
      t = (n - aa[b[i]]) + i + 1;
    }
    sol[t] = 0;
    mxd[t] = max(mxd[t], aa[b[i]] - 1);
    mxu[t] = max(mxu[t], n - aa[b[i]]);
  }
  sti = 0;
  int cur = 1;
  int mxcur = 0;
  int p = 1;
  while (p <= n) {
    if (sol[p] == 0) {
      if (cur <= mxcur) {
        st[sti][0] = p;
        st[sti][1] = cur;
        st[sti][2] = mxcur;
        sti++;
      }
      cur = 0;
      mxcur = mxd[p];
    }
    if (cur > mxcur) {
      while (sti > 0) {
        cur = st[sti - 1][1] + (p - st[sti - 1][0]);
        mxcur = st[sti - 1][2];
        sti--;
        if (cur <= mxcur) break;
      }
    }
    if (cur <= mxcur) sol[p] = min(sol[p], cur);
    cur++;
    p++;
  }
  p = 1;
  while (p <= n) {
    if (cur > mxcur) {
      while (sti > 0) {
        cur = st[sti - 1][1] + p + (n - st[sti - 1][0]);
        mxcur = st[sti - 1][2];
        sti--;
        if (cur <= mxcur) break;
      }
    }
    if (cur <= mxcur) sol[p] = min(sol[p], cur);
    cur++;
    p++;
  }
  sti = 0;
  cur = 1;
  mxcur = 0;
  p = n;
  while (p >= 1) {
    if (sol[p] == 0) {
      if (cur <= mxcur) {
        st[sti][0] = p;
        st[sti][1] = cur;
        st[sti][2] = mxcur;
        sti++;
      }
      cur = 0;
      mxcur = mxu[p];
    }
    if (cur > mxcur) {
      while (sti > 0) {
        cur = st[sti - 1][1] + (st[sti - 1][0] - p);
        mxcur = st[sti - 1][2];
        sti--;
        if (cur <= mxcur) break;
      }
    }
    if (cur <= mxcur) sol[p] = min(sol[p], cur);
    cur++;
    p--;
  }
  p = n;
  while (p >= 1) {
    if (cur > mxcur) {
      while (sti > 0) {
        cur = st[sti - 1][1] + (n - p) + (st[sti - 1][0]);
        mxcur = st[sti - 1][2];
        sti--;
        if (cur <= mxcur) break;
      }
    }
    if (cur <= mxcur) sol[p] = min(sol[p], cur);
    cur++;
    p--;
  }
  for (int i = 1; i <= n; i++) printf("%d\n", sol[i]);
  return 0;
}
