#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
int a[111111], b[111111], rb[111111], n, ra[111111];
multiset<int> up, dn;
vector<int> sub_up[111111], add_up[111111];
vector<int> sub_dn[111111], add_dn[111111];
int ans1[111111];
inline void solve() {
  up.clear();
  dn.clear();
  for (int i = 0; i < n; ++i) {
    add_up[i].clear();
    add_dn[i].clear();
    sub_up[i].clear();
    sub_dn[i].clear();
  }
  for (int i = 0; i < n; ++i) {
    if (rb[a[i]] > i) {
      dn.insert(rb[a[i]] - i);
      sub_dn[rb[a[i]] - i].push_back(rb[a[i]] - i);
      if (rb[a[i]] - i + 1 <= n - 1 - i) {
        add_up[rb[a[i]] - i + 1].push_back(-rb[a[i]] + i);
        sub_up[n - 1 - i].push_back(-rb[a[i]] + i);
      }
      add_dn[n - i].push_back(n - i + rb[a[i]]);
    } else {
      up.insert(i - rb[a[i]]);
      sub_up[n - 1 - i].push_back(i - rb[a[i]]);
      if (n - i <= n - 1 + rb[a[i]] - i) {
        add_dn[n - i].push_back(n - i + rb[a[i]]);
        sub_dn[n - 1 + rb[a[i]] - i].push_back(n - i + rb[a[i]]);
      }
      add_up[n + rb[a[i]] - i].push_back(i - n - rb[a[i]]);
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < ((int)(add_up[i]).size()); ++j) up.insert(add_up[i][j]);
    for (int j = 0; j < ((int)(add_dn[i]).size()); ++j) dn.insert(add_dn[i][j]);
    int ans = 1000000000;
    if (((int)(up).size())) ans = min(ans, *up.begin() + i);
    if (((int)(dn).size())) ans = min(ans, *dn.begin() - i);
    for (int j = 0; j < ((int)(sub_up[i]).size()); ++j)
      up.erase(up.find(sub_up[i][j]));
    for (int j = 0; j < ((int)(sub_dn[i]).size()); ++j)
      dn.erase(dn.find(sub_dn[i][j]));
    ans1[i] = ans;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    --a[i];
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", &b[i]);
    --b[i];
  }
  reverse(a, a + n);
  reverse(b, b + n);
  for (int i = 0; i < n; ++i) swap(a[i], b[i]);
  for (int i = 0; i < n; ++i) rb[b[i]] = i;
  solve();
  for (int i = 0; i < n; ++i) printf("%d\n", ans1[i]);
}
