#include <bits/stdc++.h>
using namespace std;
int pos1[100011];
int pos2[100011];
int val[100011];
int main() {
  int n;
  cin >> n;
  int a[n], b[2 * n];
  for (int i = 0; i < n; i++) cin >> a[i], a[i]--, pos1[a[i]] = i;
  for (int i = 0; i < n; i++) cin >> b[i], b[i]--, pos2[b[i]] = i;
  set<pair<int, int> > p1, p2;
  for (int i = 0; i < n; i++) {
    if (pos1[a[i]] >= pos2[a[i]]) {
      p1.insert(make_pair(abs(pos1[a[i]] - pos2[a[i]]), a[i]));
      val[a[i]] = abs(pos1[a[i]] - pos2[a[i]]);
    } else {
      p2.insert(make_pair(abs(pos1[a[i]] - pos2[a[i]]), a[i]));
    }
  }
  int ans;
  for (int second = 0; second < n; second++) {
    while (p2.size() > 0 and (*p2.begin()).first - second <= 0) {
      pair<int, int> r = *p2.begin();
      p2.erase(r);
      r.first = -second;
      val[r.second] = r.first;
      p1.insert(r);
    }
    ans = n + 2;
    if (p1.size()) ans = min(ans, p1.begin()->first + second);
    if (p2.size()) ans = min(ans, p2.begin()->first - second);
    cout << ans << "\n";
    pos2[b[second]] = n - 1;
    p2.insert(make_pair(second + 1 + abs(pos1[b[second]] - pos2[b[second]]),
                        b[second]));
    p1.erase(make_pair(val[b[second]], b[second]));
  }
}
