#include <bits/stdc++.h>
using namespace std;
set<pair<int, int> > s;
set<pair<int, int> >::iterator it;
vector<int> reponse;
int main() {
  int n, i, j, x;
  int a[100001], b[100000], t[100000], possible, possible2;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> j;
    a[j] = i;
  }
  for (i = 0; i < n; i++) {
    cin >> b[i];
  }
  for (i = 0; i < n; i++) {
    t[i] = i - a[b[i]];
    s.insert(pair<int, int>(t[i], i));
  }
  reponse.resize(n);
  for (i = 0; i < n; i++) {
    it = s.lower_bound(pair<int, int>(-i, 0));
    if (it != s.end()) {
      possible = it->first + i;
    }
    if (it != s.begin()) {
      it--;
      possible2 = -i - it->first;
    }
    if (i == 0)
      reponse[0] = min(possible, possible2);
    else
      reponse[n - i] = min(possible, possible2);
    if (i != n - 1) {
      x = t[n - 1 - i];
      it = s.lower_bound(pair<int, int>(x, 0));
      s.erase(it);
      s.insert(pair<int, int>(x - n, i + n));
    }
  }
  for (i = 0; i < n; i++) {
    printf("%d\n", reponse[i]);
  }
  return 0;
}
