#include <bits/stdc++.h>
using namespace std;
int a[100100];
int b[100100];
int occ[100100];
int vadd[100100];
int vsub[100100];
vector<pair<int, int> > add[100100];
vector<pair<int, int> > sub[100100];
set<pair<int, int> > A, S;
int main() {
  int n;
  scanf("%d", &n);
  if (n == 1) {
    printf("%d", 0);
    printf("\n");
    return 0;
  }
  for (int i = (1); i <= (n); i++) {
    scanf("%d", &a[i]);
    occ[a[i]] = i;
    add[i] = *new vector<pair<int, int> >();
    sub[i] = *new vector<pair<int, int> >();
  }
  for (int i = (1); i <= (n); i++) scanf("%d", &b[i]);
  for (int i = (1); i <= (n); i++) {
    if (occ[b[i]] == 1) {
      sub[0].push_back(make_pair(i - 1, (-1) * i));
      sub[i].push_back(make_pair(i - 1, (1) * i));
      sub[i].push_back(make_pair(n - 1, (-1) * i));
      sub[n].push_back(make_pair(n - 1, (1) * i));
    } else if (occ[b[i]] == n) {
      add[0].push_back(make_pair(n - i, (-1) * i));
      add[i].push_back(make_pair(n - i, (1) * i));
      add[i].push_back(make_pair(0, (-1) * i));
      add[n].push_back(make_pair(0, (1) * i));
    } else {
      if (occ[b[i]] <= i) {
        int a = abs(i - occ[b[i]]);
        int d = i - occ[b[i]];
        sub[0].push_back(make_pair(a, (-1) * i));
        sub[d + 1].push_back(make_pair(a, (1) * i));
        d++;
        int d2 = i - 1;
        add[d].push_back(make_pair(1, (-1) * i));
        add[d2 + 1].push_back(make_pair(1, (1) * i));
        d = d2 + 1;
        d2 = n - 1;
        a = abs(n - occ[b[i]]);
        sub[d].push_back(make_pair(a, (-1) * i));
        sub[d2 + 1].push_back(make_pair(a, (1) * i));
      } else {
        int a = abs(i - occ[b[i]]);
        int d = i - 1;
        add[0].push_back(make_pair(a, (-1) * i));
        add[d + 1].push_back(make_pair(a, (1) * i));
        d++;
        int d2 = n - a;
        a = abs(n - occ[b[i]]);
        sub[d].push_back(make_pair(a, (-1) * i));
        sub[d2 + 1].push_back(make_pair(a, (1) * i));
        d = d2 + 1;
        d2 = n - 1;
        add[d].push_back(make_pair(1, (-1) * i));
        add[d2 + 1].push_back(make_pair(1, (1) * i));
      }
    }
  }
  A = *new set<pair<int, int> >();
  S = *new set<pair<int, int> >();
  int x = 0, y = 0;
  for (int i = (0); i < (n); i++) {
    for (int j = (0); j < (add[i].size()); j++) {
      if (add[i][j].second <= 0) {
        int k = add[i][j].second / (-1);
        vadd[k] = add[i][j].first - x;
        A.insert(make_pair(vadd[k], add[i][j].second));
      } else {
        int k = add[i][j].second / (1);
        A.erase(make_pair(vadd[k], -add[i][j].second));
      }
    }
    for (int j = (0); j < (sub[i].size()); j++) {
      if (sub[i][j].second <= 0) {
        int k = sub[i][j].second / (-1);
        vsub[k] = sub[i][j].first - y;
        S.insert(make_pair(vsub[k], sub[i][j].second));
      } else {
        int k = sub[i][j].second / (1);
        S.erase(make_pair(vsub[k], -sub[i][j].second));
      }
    }
    int av = (A.begin()->first) + x, sv = (S.begin()->first) + y;
    printf("%d", (((av) < (sv)) ? (av) : (sv)));
    printf("\n");
    x++;
    y--;
  }
}
