#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100100;
struct shift {
  int val, idx;
  shift(int val_ = 0, int idx_ = 0) {
    val = val_;
    idx = idx_;
  }
  bool operator<(const shift& p) const { return val > p.val; }
};
int n;
int dp[MAXN], b[MAXN];
bool used[MAXN];
priority_queue<shift> l, r;
void read() {
  int i, a;
  scanf("%d", &n);
  for (i = 1; i <= n; ++i) {
    scanf("%d", &a);
    dp[a] = i;
  }
  for (i = 1; i <= n; ++i) {
    scanf("%d", &b[i]);
  }
}
int minimum(int num1, int num2) {
  if (num1 < 0) num1 *= -1;
  if (num2 < 0) num2 *= -1;
  if (num1 < num2) return num1;
  return num2;
}
void solve() {
  int i;
  l.push(shift(MAXN, MAXN));
  r.push(shift(MAXN, MAXN));
  for (i = 1; i <= n; ++i) {
    if (i <= dp[b[i]])
      r.push(shift(dp[b[i]] - i, i));
    else
      l.push(shift(i - dp[b[i]], i));
  }
  printf("%d\n", minimum(r.top().val, l.top().val));
  for (i = 1; i < n; ++i) {
    used[i] = 1;
    l.push(shift(n - dp[b[i]] + i, i));
    while (l.top().val - i == 0) {
      shift tc = l.top();
      l.pop();
      used[tc.idx] = 0;
      tc.val *= -1;
      r.push(tc);
    }
    while (used[r.top().idx]) {
      r.pop();
    }
    printf("%d\n", minimum(l.top().val - i, r.top().val + i));
  }
}
int main() {
  read();
  solve();
  return 0;
}
