#include <bits/stdc++.h>
using namespace std;
int a[100005];
int b[100005];
int poi[100005];
int vis[100005];
int main(int argc, char** argv) {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), poi[a[i]] = i;
  for (int i = 1; i <= n; i++) scanf("%d", &b[i]), b[i + n] = b[i];
  int j = n;
  set<pair<int, int> > sz0, sy0, sy1, sz1;
  int minn = 1e9;
  for (int i = 1; i <= n; i++) {
    int u = poi[b[i]] - i;
    if (u >= 0)
      sy0.insert({u, b[i]});
    else {
      sz0.insert({-u, b[i]});
    }
    minn = min(abs(u), minn);
  }
  printf("%d\n", minn);
  int now = 0;
  while (++j < 2 * n) {
    vis[b[j]] = 1;
    now++;
    set<pair<int, int> >::iterator it, q;
    while (sz0.size()) {
      it = sz0.begin();
      if (now - (*it).first != 0) break;
      sy0.insert({-now, (*it).second});
      sz0.erase(it);
    }
    while (sz1.size()) {
      it = sz1.begin();
      if (now - (*it).first != 0) break;
      sy1.insert({-now, (*it).second});
      sz1.erase(it);
    }
    vis[b[j]] = 1;
    if (poi[b[j]] + now == j)
      sy1.insert({-now, b[j]});
    else
      sz1.insert({j - poi[b[j]], b[j]});
    while (sz0.size()) {
      it = sz0.begin();
      if (vis[(*it).second])
        sz0.erase(it);
      else
        break;
    }
    while (sy0.size()) {
      it = sy0.begin();
      if (vis[(*it).second])
        sy0.erase(it);
      else
        break;
    }
    int f = 1e9;
    if (sz0.size()) q = sz0.begin(), f = min(f, (*q).first - now);
    if (sz1.size()) q = sz1.begin(), f = min(f, (*q).first - now);
    if (sy0.size()) q = sy0.begin(), f = min(f, (*q).first + now);
    if (sy1.size()) q = sy1.begin(), f = min(f, (*q).first + now);
    printf("%d\n", f);
  }
  return 0;
}
