#include <bits/stdc++.h>
using namespace std;
int a1[200000];
int a2[200000];
int pos[200000];
vector<int> d[200000];
int ll[200000];
int rr[200000];
int tt[200000];
int ans[200000];
int main() {
  int i, j, n, tmp;
  vector<pair<int, int> > q;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &a1[i]);
    pos[a1[i]] = i;
  }
  for (i = 0; i < n; i++) scanf("%d", &a2[i]);
  for (i = 0; i <= n; i++) d[i].clear();
  for (i = 0; i < n; i++) {
    tmp = pos[a2[i]];
    if (tmp <= i)
      tt[a2[i]] = i - tmp;
    else
      tt[a2[i]] = i + n - tmp;
    ll[a2[i]] = n - 1 - tmp;
    rr[a2[i]] = tmp;
    d[tt[a2[i]]].push_back(a2[i]);
  }
  for (i = 0; i < n; i++) ans[i] = 2000000000;
  q.clear();
  for (i = 0; i < n; i++)
    for (j = 0; j < d[i].size(); j++)
      q.push_back(make_pair(d[i][j], tt[d[i][j]] - n));
  for (i = 0; i < n; i++) {
    for (j = 0; j < d[i].size(); j++)
      q.push_back(make_pair(d[i][j], tt[d[i][j]]));
    while (q.size() > 0) {
      pair<int, int> p = q[q.size() - 1];
      if (rr[p.first] < i - p.second) {
        q.pop_back();
      } else {
        break;
      }
    }
    if (q.size() > 0) {
      if (i - q[q.size() - 1].second < ans[i])
        ans[i] = i - q[q.size() - 1].second;
    }
  }
  q.clear();
  for (i = n - 1; i >= 0; i--)
    for (j = 0; j < d[i].size(); j++)
      q.push_back(make_pair(d[i][j], tt[d[i][j]] + n));
  for (i = n - 1; i >= 0; i--) {
    for (j = 0; j < d[i].size(); j++)
      q.push_back(make_pair(d[i][j], tt[d[i][j]]));
    while (q.size() > 0) {
      pair<int, int> p = q[q.size() - 1];
      if (ll[p.first] < p.second - i) {
        q.pop_back();
      } else {
        break;
      }
    }
    if (q.size() > 0) {
      if (q[q.size() - 1].second - i < ans[i])
        ans[i] = q[q.size() - 1].second - i;
    }
  }
  for (i = 0; i < n; i++) printf("%d\n", ans[i]);
}
