#include <bits/stdc++.h>
using namespace std;
map<int, int> mapa;
int a[110000];
int b[110000];
int n;
vector<int> esq[2 * 110000], dir[2 * 110000];
int ans[110000 + 110000];
int dist(int a, int b) {
  if (b >= a) return b - a;
  return n - (dist(b, a));
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < n; i++) scanf("%d", &b[i]);
  for (int i = 0; i < n; i++) mapa[a[i]] = i;
  for (int i = 0; i < n + n; i++) ans[i] = 110000 + 110000;
  for (int i = 0; i < n; i++) {
    int x = dist(mapa[b[i]], i);
    int j = mapa[b[i]];
    esq[n + x - (n - 1 - j)].push_back(n + x);
    dir[x + j].push_back(x);
  }
  set<int> S;
  for (int i = 0; i < 2 * n; i++) {
    for (int j = 0; j < esq[i].size(); j++) S.insert(esq[i][j]);
    if (S.size()) ans[i] = min(ans[i], abs(i - (*S.begin())));
    while (S.size() && (*S.begin()) == i) S.erase(S.find(i));
  }
  for (int i = 0; i < n; i++) ans[i] = min(ans[i], ans[i + n]);
  S.clear();
  for (int i = 2 * n - 1; i >= 0; i--) {
    for (int j = 0; j < dir[i].size(); j++) S.insert(-dir[i][j]);
    if (S.size()) ans[i] = min(ans[i], abs(i + (*S.begin())));
    while (S.size() && (*S.begin()) == -i) S.erase(S.find(-i));
  }
  for (int i = 0; i < n; i++) ans[i] = min(ans[i], ans[i + n]);
  for (int i = 0; i < n; i++) printf("%d\n", ans[i]);
  return 0;
}
