#include <bits/stdc++.h>
#pragma GCC optimize("O3")
const double PI = acos(-1);
using namespace std;
const int MAX = 100 * 1000 + 10;
int A[MAX], B[MAX], n, pos[MAX];
int diff[MAX << 1];
int mx[MAX], mn[MAX];
deque<int> dq;
const int oo = 1 << 28;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < (n); i++) {
    scanf("%d", A + i);
    pos[A[i]] = i;
  }
  for (int i = 0; i < (n); i++) scanf("%d", B + i);
  map<int, int> M;
  for (int i = 0; i < (n); i++) M[i - pos[B[i]]]++;
  int offset = 0;
  for (int i = 0; i < (n); i++) {
    auto p = M.lower_bound(offset);
    int ans = INT_MAX;
    if (p != M.end()) ans = abs(p->first - offset);
    if (p != M.begin()) {
      --p;
      ans = min(ans, abs(p->first - offset));
    }
    printf("%d\n", ans);
    offset++;
    int x = i - pos[B[i]];
    M[x]--;
    if (M[x] == 0) M.erase(x);
    x = (i + n) - pos[B[i]];
    M[x]++;
  }
  return 0;
}
