#include <bits/stdc++.h>
using namespace std;
int a[101111], b[101111], n;
int ap[101111], bp[101111];
int value[101111], status[101111];
int ans[101111];
struct node {
  int u, v, n, next;
} e[101111 * 2];
int tot, last[101111];
map<int, int> S1, S2;
void adde(int u, int v) {
  e[tot].u = u;
  e[tot].v = v;
  e[tot].next = last[u];
  last[u] = tot++;
}
int getans(int x) {
  int ret = 101111;
  int i, j, k, u, v, w;
  pair<int, int> tp;
  if (S1.begin() != S1.end()) {
    tp = *(S1.begin());
    ret = min(ret, tp.first - x);
  }
  if (S2.begin() != S2.end()) {
    tp = *(S2.begin());
    ret = min(ret, tp.first + x);
  }
  ans[x] = ret;
  return ret;
}
void del(map<int, int> &S, int w) {
  S[w]--;
  if (S[w] == 0) S.erase(w);
}
void change(int x) {
  int i, j, k, u, v, w;
  for (j = last[x]; j != -1; j = e[j].next) {
    v = e[j].v;
    w = value[v];
    if (status[v] == 1) {
      del(S1, w);
      value[v] = -x;
      S2[value[v]]++;
    } else {
      del(S2, w);
      S1[value[v]]++;
    }
    status[v] *= -1;
  }
  if (status[b[x]] == 1) {
    del(S1, value[b[x]]);
  } else if (status[b[x]] == -1) {
    del(S2, value[b[x]]);
  }
  bp[b[x]] = n - 1;
  if (ap[b[x]] <= bp[b[x]]) {
    value[b[x]] = x + 1 + bp[b[x]] - ap[b[x]];
    S1[value[b[x]]]++;
    status[b[x]] = 1;
  }
}
int main() {
  int i, j, k, u, v, w;
  while (cin >> n) {
    for (i = 0; i < n; i++) {
      cin >> a[i];
      a[i]--;
      ap[a[i]] = i;
    }
    for (i = 0; i < n; i++) {
      cin >> b[i];
      b[i]--;
      bp[b[i]] = i;
    }
    memset(last, -1, sizeof(last));
    tot = 0;
    memset(status, 0, sizeof(status));
    S1.clear();
    S2.clear();
    for (i = 0; i < n; i++) {
      if (ap[i] <= bp[i]) {
        adde(bp[i] - ap[i], i);
        value[i] = abs(bp[i] - ap[i]);
        S1[value[i]]++;
        status[i] = 1;
      } else {
        adde(n - (ap[i] - bp[i]), i);
        value[i] = abs(bp[i] - ap[i]);
        S2[abs(value[i])]++;
        status[i] = -1;
      }
    }
    for (i = 0; i < n; i++) {
      getans(i);
      change(i);
    }
    for (i = 0; i < n; i++) printf("%d\n", ans[i]);
  }
  return 0;
}
