#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return a == 0 ? b : gcd(b % a, a); }
const string filename = "test";
const string str_fin = filename + ".in";
const string str_fout = filename + ".out";
vector<vector<pair<int, int> > > v_up, v_down;
set<pair<int, int> > q_up, q_down;
void insertDown(int index, const pair<int, int>& down) {
  if (index >= v_down.size()) return;
  if (down.second <= 0) return;
  v_down[index].push_back(down);
}
void insertUp(int index, const pair<int, int>& up) {
  if (index >= v_up.size()) return;
  if (up.second <= 0) return;
  v_up[index].push_back(up);
}
int processVQ(vector<pair<int, int> >& v, set<pair<int, int> >& q, int index,
              int mul) {
  for (int _n(v.size()), i(0); i < _n; i++) {
    q.insert(pair<int, int>(v[i].first + mul * index, v[i].second + index - 1));
  }
  while (!q.empty()) {
    const pair<int, int>& x = *q.begin();
    if (x.second >= index) {
      return x.first - mul * index;
    }
    q.erase(q.begin());
  }
  return 1000000;
}
int process(int index) {
  if (index == 0) {
    q_up.clear();
    q_down.clear();
  }
  int r_up = processVQ(v_up[index], q_up, index, -1);
  int r_down = processVQ(v_down[index], q_down, index, 1);
  return (((r_up) < (r_down)) ? (r_up) : (r_down));
}
int main() {
  int n, x;
  scanf("%d", &n);
  vector<int> va, vb;
  va.reserve(n);
  vb.reserve(n);
  v_up = vector<vector<pair<int, int> > >(n);
  v_down = vector<vector<pair<int, int> > >(n);
  vector<int> vpos_a(n + 1, -1), vpos_b(n + 1, -1);
  for (int _n(n), i(0); i < _n; i++) {
    scanf("%d", &x);
    va.push_back(x);
    vpos_a[x] = i;
  }
  for (int _n(n), i(0); i < _n; i++) {
    scanf("%d", &x);
    vb.push_back(x);
    vpos_b[x] = i;
  }
  for (int _n(n + 1), i(1); i < _n; i++) {
    int pa = vpos_a[i], push_back = vpos_b[i];
    if (push_back == pa) {
      insertUp(0, pair<int, int>(0, n - pa));
      insertDown(n - pa, pair<int, int>(pa, pa));
    } else if (push_back > pa) {
      insertUp(0, pair<int, int>(push_back - pa, n - push_back));
      insertDown(n - push_back, pair<int, int>(pa, pa));
      insertUp(n - push_back + pa, pair<int, int>(0, push_back - pa));
    } else {
      insertDown(0, pair<int, int>(pa - push_back, pa - push_back));
      insertUp(pa - push_back, pair<int, int>(0, n - pa));
      insertDown(n - push_back, pair<int, int>(pa, push_back));
    }
  }
  vector<int> res;
  for (int _n(n), i(0); i < _n; i++) {
    res.push_back(process(i));
  }
  reverse(res.begin() + 1, res.end());
  for (int _n(res.size()), i(0); i < _n; i++) {
    printf("%d\n", res[i]);
  }
  return 0;
}
