#include <bits/stdc++.h>
using namespace std;
long long int powmod(long long int a, int b, int n) {
  long long int rm = 1;
  while (b) {
    if (b % 2) {
      rm = (rm * a) % n;
    }
    a = (a * a) % n;
    b /= 2;
  }
  return rm;
}
set<pair<int, int> > Left, Right;
int n, a[int(1e5 + 10)], b[int(1e5 + 10)], ind[int(1e5 + 10)];
int main() {
  cin >> n;
  for (int i = int(1); i <= (int)n; i++) cin >> b[i];
  for (int i = int(1); i <= (int)n; i++) {
    cin >> a[i];
    ind[b[i]] = i;
  }
  for (int i = 1; i <= n; ++i) {
    if (ind[a[i]] <= i) {
      Right.insert(make_pair(i - ind[a[i]], i));
    } else {
      Left.insert(make_pair(ind[a[i]] - i, i));
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (i > 1) {
      if (ind[a[i - 1]] <= 1) {
        Right.erase(Right.find(make_pair(i - 2 + 0, i - 1)));
      } else {
        Left.erase(Left.find(make_pair(ind[a[i - 1]] - 1 - (i - 2), i - 1)));
      }
      while (!Right.empty()) {
        if ((*Right.begin()).first >= i - 1) break;
        pair<int, int> tmp = *Right.begin();
        Right.erase(Right.find(tmp));
        if (tmp.second - (i - 1) >= 1)
          tmp.first = tmp.second - (i - 1);
        else
          tmp.first = n + (tmp.second - (i - 1));
        tmp.first = 1;
        tmp.first -= i - 1;
        Left.insert(tmp);
      }
      Right.insert(make_pair(n - ind[a[i - 1]] + i - 1, i - 1));
    }
    int ans =
        min((*Right.begin()).first - (i - 1), (*Left.begin()).first + (i - 1));
    printf("%d\n", ans);
  }
  return 0;
}
