#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const int MOD = 1e9 + 7;
const int N = 1e5 + 10;
int n, p[2][N];
int h[N];
int ans[N];
priority_queue<pair<int, int> > qd, qi;
vector<int> sw[N];
void prepare() {
  scanf("%d", &n);
  for (auto j = (0); j <= (1); j++)
    for (auto i = (1); i <= (n); i++) {
      int x;
      scanf("%d", &x);
      p[j][x] = i;
    }
  for (auto i = (1); i <= (n); i++)
    if (p[1][i] >= p[0][i]) {
      qi.push(pair<int, int>(-p[1][i] + p[0][i], i));
      h[i] = 1;
      sw[n - p[1][i] + 1].push_back(i);
      sw[n - p[1][i] + p[0][i]].push_back(i);
    }
  for (auto i = (n); i >= (1); i--)
    if (p[1][i] < p[0][i]) {
      qd.push(pair<int, int>(p[1][i] - p[0][i], i));
      sw[p[0][i] - p[1][i]].push_back(i);
      sw[n - p[1][i] + 1].push_back(i);
    }
}
void solve() {
  for (auto turn = (0); turn < (n); turn++) {
    for (auto idx : sw[turn]) {
      if (h[idx] == 1)
        qd.push(pair<int, int>(-(p[0][idx] - 1 + turn), idx));
      else
        qi.push(pair<int, int>(turn, idx));
      h[idx] ^= 1;
    }
    while (!qd.empty()) {
      int idx = qd.top().second;
      if (h[idx])
        qd.pop();
      else {
        int eans = abs(p[0][idx] - (p[1][idx] - 1 + turn) % n - 1);
        if (eans != -qd.top().first - turn)
          qd.pop();
        else
          break;
      }
    }
    while (!qi.empty()) {
      int idx = qi.top().second;
      if (!h[idx])
        qi.pop();
      else {
        int eans = abs(p[0][idx] - (p[1][idx] - 1 + turn) % n - 1);
        if (eans != -qi.top().first + turn)
          qi.pop();
        else
          break;
      }
    }
    int cans = n + 1;
    if (!qd.empty()) {
      cans = min(cans, -qd.top().first - turn);
    }
    if (!qi.empty()) {
      cans = min(cans, -qi.top().first + turn);
    }
    ans[(n - turn) % n] = cans;
  }
  for (auto i = (0); i < (n); i++) printf("%d\n", ans[i]);
}
int main() {
  prepare();
  solve();
}
