#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
struct pi {
  int le, ri;
  int la1, la2;
} pp[maxn << 2];
void build(int tot, int l, int r) {
  pp[tot].le = l;
  pp[tot].ri = r;
  pp[tot].la1 = -1;
  pp[tot].la2 = -1;
  if (l == r) return;
  build(2 * tot, l, (l + r) / 2);
  build(2 * tot + 1, (l + r) / 2 + 1, r);
}
void merg1(int tot, int l, int r, int k) {
  if (l > r) return;
  if (pp[tot].le >= l && pp[tot].ri <= r) {
    k = k + (pp[tot].le - l);
    if (pp[tot].la1 == -1)
      pp[tot].la1 = k;
    else
      pp[tot].la1 = min(pp[tot].la1, k);
    return;
  }
  int mid = (pp[tot].le + pp[tot].ri) / 2;
  if (l <= mid) {
    merg1(2 * tot, l, r, k);
  }
  if (r > mid) {
    merg1(2 * tot + 1, l, r, k);
  }
}
void merg2(int tot, int l, int r, int k) {
  if (l > r) return;
  if (pp[tot].le >= l && pp[tot].ri <= r) {
    k = k - (pp[tot].le - l);
    if (pp[tot].la2 == -1)
      pp[tot].la2 = k;
    else
      pp[tot].la2 = min(pp[tot].la2, k);
    return;
  }
  int mid = (pp[tot].le + pp[tot].ri) / 2;
  if (l <= mid) {
    merg2(2 * tot, l, r, k);
  }
  if (r > mid) {
    merg2(2 * tot + 1, l, r, k);
  }
}
int query(int tot, int x) {
  int s = 1000000000;
  if (pp[tot].la1 != -1) {
    s = min(s, pp[tot].la1 + (x - pp[tot].le));
  }
  if (pp[tot].la2 != -1) s = min(s, pp[tot].la2 - (x - pp[tot].le));
  if (pp[tot].le == pp[tot].ri) {
    return s;
  }
  int mid = (pp[tot].le + pp[tot].ri) / 2;
  if (x <= mid)
    s = min(s, query(2 * tot, x));
  else
    s = min(s, query(2 * tot + 1, x));
  return s;
}
int a[maxn], b[maxn];
int main() {
  int i, n;
  cin >> n;
  for (i = 1; i <= n; i++) {
    int p;
    scanf("%d", &p);
    a[p] = n - i + 1;
  }
  for (i = 1; i <= n; i++) {
    int p;
    scanf("%d", &p);
    b[p] = n - i + 1;
  }
  build(1, 0, n - 1);
  for (i = 1; i <= n; i++) {
    if (a[i] < b[i]) {
      merg1(1, 0, n - b[i], b[i] - a[i]);
      merg1(1, n - b[i] + a[i], n - 1, 0);
      merg2(1, n - b[i] + 1, n - b[i] + a[i], a[i] - 1);
    } else if (a[i] > b[i]) {
      merg2(1, 0, a[i] - b[i], a[i] - b[i]);
      merg2(1, n - b[i] + 1, n - 1, a[i] - 1);
      merg1(1, a[i] - b[i], n - b[i], 0);
    } else {
      merg1(1, 0, n - a[i], 0);
      merg2(1, n - a[i] + 1, n - 1, a[i] - 1);
    }
  }
  for (i = 0; i < n; i++) printf("%d\n", query(1, i));
}
