#include <bits/stdc++.h>
using namespace std;
namespace Work {
const int kMaxN = 100010;
multiset<int> set;
int n;
int a[kMaxN], b[kMaxN];
int pos[kMaxN];
void solve(FILE* fin, FILE* fout) {
  fscanf(fin, "%d", &n);
  for (int i = 1; i <= n; i++) {
    fscanf(fin, "%d", a + i);
    pos[a[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    fscanf(fin, "%d", b + i);
    set.insert(i - pos[b[i]]);
  }
  multiset<int>::iterator it = set.lower_bound(0);
  int x = *it, y = x;
  if (it != set.begin()) {
    it--;
    y = *it;
  }
  fprintf(fout, "%d\n", min(abs(x), abs(y)));
  for (int dt = 1; dt < n; dt++) {
    set.erase(set.find(dt - pos[b[dt]]));
    set.insert(n - pos[b[dt]] + dt);
    it = set.lower_bound(dt);
    x = *it, y = x;
    if (it != set.begin()) {
      it--;
      y = *it;
    }
    fprintf(fout, "%d\n", min(abs(x - dt), abs(y - dt)));
  }
  return;
}
}  // namespace Work
int main() {
  Work::solve(stdin, stdout);
  return 0;
}
