#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < n; ++i) {
    cin >> b[i];
  }
  vector<int> rev(n);
  for (int i = 0; i < n; ++i) {
    --a[i];
    --b[i];
    rev[a[i]] = i;
  }
  vector<vector<int> > incr_push(n + 1);
  vector<vector<int> > incr_pop(n + 1);
  vector<vector<int> > decr_push(n + 1);
  vector<vector<int> > decr_pop(n + 1);
  for (int i = 0; i < n; ++i) {
    const int p = rev[b[i]];
    if (p >= i) {
      const int x1 = i + 1;
      const int x2 = x1 + n - p - 1;
      incr_push[0].push_back(p - i);
      incr_pop[x1].push_back(p - i);
      decr_push[x1].push_back(x2);
      decr_pop[x2].push_back(x2);
      incr_push[x2].push_back(-x2);
    } else {
      const int x1 = i - p;
      const int x2 = i + 1;
      decr_push[0].push_back(x1);
      decr_pop[x1].push_back(x1);
      incr_push[x1].push_back(-x1);
      incr_pop[x2].push_back(-x1);
      decr_push[x2].push_back(n - i - 1 + x2);
    }
  }
  multiset<int> incr, decr;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < incr_push[i].size(); ++j) {
      incr.insert(incr_push[i][j]);
    }
    for (int j = 0; j < incr_pop[i].size(); ++j) {
      incr.erase(incr.find(incr_pop[i][j]));
    }
    for (int j = 0; j < decr_push[i].size(); ++j) {
      decr.insert(decr_push[i][j]);
    }
    for (int j = 0; j < decr_pop[i].size(); ++j) {
      decr.erase(decr.find(decr_pop[i][j]));
    }
    int incr_v = INF, decr_v = INF;
    if (!incr.empty()) {
      incr_v = *(incr.begin()) + i;
    }
    if (!decr.empty()) {
      decr_v = *(decr.begin()) - i;
    }
    cout << min(incr_v, decr_v) << endl;
  }
  return 0;
}
