#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:200000000")
const double EPS = 1E-9;
const int INF = 1000000000;
const long long INF64 = (long long)1E18;
const double PI = 3.1415926535897932384626433832795;
const int NMAX = 110000;
int a[NMAX], b[NMAX], ans[NMAX], x[NMAX], y[NMAX], v1[NMAX], v2[NMAX];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < (int)(n); i++) scanf("%d", &a[i]);
  for (int i = 0; i < (int)(n); i++) scanf("%d", &b[i]);
  if (n == 1) {
    puts("0");
    return 0;
  }
  for (int i = 0; i < (int)(n); i++) {
    a[i]--;
    b[i]--;
  }
  for (int i = 0; i < (int)(n); i++) {
    x[a[i]] = i;
    y[b[i]] = i;
  }
  set<pair<int, int> > q1, q2;
  ans[0] = INF;
  for (int i = 0; i < (int)(n); i++)
    if (x[i] <= y[i]) {
      v1[i] = y[i] - x[i];
      v2[i] = -1;
      q1.insert(make_pair(y[i] - x[i], i));
      ans[0] = min(ans[0], y[i] - x[i]);
    } else {
      v2[i] = x[i] - y[i];
      v1[i] = -1;
      q2.insert(make_pair(x[i] - y[i], i));
      ans[0] = min(ans[0], x[i] - y[i]);
    }
  int b1 = 0, b2 = 0;
  for (int i = 1; i < n; i++) {
    int id = b[i - 1];
    if (v1[id] == -1) {
      q2.erase(make_pair(v2[id], id));
    } else {
      q1.erase(make_pair(v1[id], id));
    }
    v1[id] = n - 1 - x[id] + i;
    v2[id] = -1;
    q1.insert(make_pair(v1[id], id));
    while (!q1.empty() && q1.begin()->first < i) {
      int id = q1.begin()->second;
      q1.erase(q1.begin());
      v1[id] = -1;
      v2[id] = 1 - i;
      q2.insert(make_pair(v2[id], id));
    }
    ans[i] = INF;
    if (!q1.empty()) {
      ans[i] = min(ans[i], q1.begin()->first - i);
    }
    if (!q2.empty()) {
      ans[i] = min(ans[i], q2.begin()->first + i);
    }
  }
  for (int i = 0; i < (int)(n); i++) printf("%d\n", ans[i]);
  return 0;
}
