#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000000;
int a[100000], b[100000], value[100000], locA[100000], locB[100000],
    sign[100000];
vector<int> change[100000];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < n; i++) scanf("%d", &b[i]);
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      plus, minus;
  for (int i = 0; i < n; i++) {
    a[i]--;
    b[i]--;
    locA[a[i]] = i;
    locB[b[i]] = i;
  }
  for (int i = 0; i < n; i++) {
    int x = a[i];
    value[x] = abs(i - locB[x]);
    if (locB[x] < i) {
      sign[x] = 1;
      plus.push(make_pair(value[x], x));
      change[locB[x] + n - i].push_back(x);
    } else {
      sign[x] = -1;
      minus.push(make_pair(value[x], x));
      change[locB[x] - i].push_back(x);
    }
    change[i].push_back(b[i]);
  }
  for (int i = 0; i < n; i++) {
    while (!plus.empty()) {
      pair<int, int> tmp = plus.top();
      int x = tmp.second;
      if (tmp.first + i == abs((locB[x] - i + n) % n - locA[x]) && sign[x] == 1)
        break;
      plus.pop();
    }
    while (!minus.empty()) {
      pair<int, int> tmp = minus.top();
      int x = tmp.second;
      if (tmp.first - i == abs((locB[x] - i + n) % n - locA[x]) &&
          sign[x] == -1)
        break;
      minus.pop();
    }
    int t1 = plus.empty() ? inf : plus.top().first + i;
    int t2 = minus.empty() ? inf : minus.top().first - i;
    printf("%d\n", min(t1, t2));
    for (int j = 0; j < change[i].size(); j++) {
      int x = change[i][j];
      sign[x] *= -1;
      value[x] = abs((locB[x] - (i + 1) + n) % n - locA[x]);
      if (sign[x] == 1) {
        plus.push(make_pair(value[x] - (i + 1), x));
      } else {
        minus.push(make_pair(value[x] + (i + 1), x));
      }
    }
  }
  return 0;
}
