#include <bits/stdc++.h>
using namespace std;
const int IINF = 1 << 28;
const double INF = 1e30;
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < n; ++i) {
    cin >> b[i];
  }
  vector<int> x(n);
  vector<int> y(n);
  for (int i = 0; i < n; ++i) {
    x[--a[i]] = i;
    y[--b[i]] = i;
  }
  multiset<int> dist;
  for (int i = 0; i < n; ++i) {
    dist.insert(y[i] - x[i]);
  }
  for (int i = 0; i < n; ++i) {
    int res = IINF;
    multiset<int>::iterator it = dist.lower_bound(i);
    res = min(res, *it - i);
    if (it != dist.begin()) {
      res = min(res, abs((*--it) - i));
    }
    cout << res << endl;
    int head = b[i];
    dist.erase(dist.find(y[head] - x[head]));
    dist.insert(n - 1 - x[head] + i + 1);
  }
}
