#include <bits/stdc++.h>
using namespace std;
const int N = 101000;
int n, pos[N], z[N];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    pos[x] = i;
  }
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    z[i] = i - pos[x];
  }
  map<int, int> Map;
  for (int i = 0; i < n; i++) {
    Map[z[i]]++;
  }
  for (int i = 0; i < n; i++) {
    map<int, int>::iterator it = Map.upper_bound(i);
    int ans = n + 1;
    if (it != Map.end()) {
      ans = min(ans, it->first - i);
    }
    if (it != Map.begin()) {
      ans = min(ans, i - (--it)->first);
    }
    printf("%d\n", ans);
    int val = z[i];
    Map[z[i]]--;
    if (Map[z[i]] == 0) {
      Map.erase(z[i]);
    }
    Map[z[i] + n]++;
  }
  return 0;
}
