#include <bits/stdc++.h>
using namespace std;
template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  os << "{" << p.first << "," << p.second << "}";
  return os;
}
const int N = 3e5 + 5;
const int oo = 1e9 + 7;
int incr[N << 2];
int decr[N << 2];
void build(int u, int ss, int se) {
  if (ss == se) {
    incr[u] = oo;
    decr[u] = oo;
  } else {
    int mid = (ss + se) / 2;
    build(u << 1, ss, mid);
    build(u << 1 | 1, mid + 1, se);
    incr[u] = oo;
    decr[u] = oo;
  }
}
void update_incr(int u, int ss, int se, int qs, int qe, int x) {
  if (qe < ss or se < qs) return;
  if (qs <= ss and se <= qe) {
    incr[u] = min(incr[u], x + (ss - qs));
  } else {
    int mid = (ss + se) / 2;
    update_incr(u << 1, ss, mid, qs, qe, x);
    update_incr(u << 1 | 1, mid + 1, se, qs, qe, x);
  }
}
void update_decr(int u, int ss, int se, int qs, int qe, int x) {
  if (qe < ss or se < qs) return;
  if (qs <= ss and se <= qe) {
    decr[u] = min(decr[u], x - (ss - qs));
  } else {
    int mid = (ss + se) / 2;
    update_decr(u << 1, ss, mid, qs, qe, x);
    update_decr(u << 1 | 1, mid + 1, se, qs, qe, x);
  }
}
int val(int u, int ss, int se, int x, int lazy) {
  assert(ss <= x and x <= se);
  lazy = min(lazy, incr[u] + (x - ss));
  lazy = min(lazy, decr[u] - (x - ss));
  if (ss == se) {
    return lazy;
  } else {
    int mid = (ss + se) / 2;
    if (x <= mid)
      return val(u << 1, ss, mid, x, lazy);
    else
      return val(u << 1 | 1, mid + 1, se, x, lazy);
  }
}
int a[N];
int b[N];
int ai[N];
int bi[N];
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    ai[a[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    cin >> b[i];
    bi[b[i]] = i;
  }
  build(1, 1, n);
  for (int i = 1; i <= n; i++) {
    int x = ai[i];
    int y = bi[i];
    if (x <= y) {
      int d = y - x;
      update_decr(1, 1, n, 1, d + 1, d);
      update_incr(1, 1, n, d + 1, y, 0);
      d = n - x;
      update_decr(1, 1, n, y + 1, n, d);
    } else {
      int d = x - y;
      update_incr(1, 1, n, 1, y, d);
      d = n - x;
      update_decr(1, 1, n, y + 1, y + 1 + d, d);
      update_incr(1, 1, n, y + 1 + d, n, 0);
    }
  }
  for (int i = 1; i <= n; i++) cout << val(1, 1, n, i, oo) << "\n";
}
