#include <bits/stdc++.h>
using namespace std;
const long long N = 300005;
long long fa[N], dep[N], sz[N], mid[N], gs[N];
long long n, q;
long long S[N], val[N];
vector<long long> e[N], siz[N];
vector<long long> p[N];
long long dfs1(long long u, long long d) {
  dep[u] = d;
  sz[u] = 1;
  long long cnt = 0;
  for (auto &v : e[u]) {
    dfs1(v, d + 1);
    siz[u].push_back(v);
    gs[v] = cnt++;
    sz[u] += sz[v];
  }
  return sz[u];
}
long long dfs2(long long u) {
  for (auto &v : e[u]) {
    long long res = dfs2(v);
    p[u].push_back(res);
    S[u] += res;
  }
  S[u] += sz[u] - 1;
  if (e[u].size() == 0) {
    return S[u] = 0;
  }
  return S[u];
}
long long dfs3(long long u) {
  for (auto &v : e[u]) dfs3(v);
  long long Min = S[u];
  long long id = u;
  for (long long i = 0; i < e[u].size(); ++i) {
    long long v = e[u][i];
    long long t = mid[v];
    val[v] += (S[u] - S[v]) - sz[v] + (sz[u] - sz[v]) * (dep[t] - dep[u]);
    if (val[v] < Min) Min = val[v], id = t;
    while (t != v) {
      long long newval = val[v];
      newval -= (S[u] - S[v]) - sz[v] + (sz[u] - sz[v]) * (dep[t] - dep[u]);
      newval -= (sz[v] - sz[t]);
      newval += sz[t];
      t = fa[t];
      newval += (S[u] - S[v]) - sz[v] + (sz[u] - sz[v]) * (dep[t] - dep[u]);
      if (newval > val[v]) break;
      val[v] = newval;
      if (newval < Min) Min = val[v], id = t;
    }
  }
  val[u] = Min, mid[u] = id;
  if (e[u].size() == 0) {
    mid[u] = u;
    val[u] = 0;
    return -1;
  }
  return id;
}
template <typename T>
void show(T a[]) {
  for (long long i = 1; i <= n; ++i) cout << a[i] << " ";
  cout << endl;
}
int32_t main() {
  cin >> n >> q;
  for (long long i = 2; i <= n; ++i) cin >> fa[i], e[fa[i]].emplace_back(i);
  dfs1(1, 1), dfs2(1);
  dfs3(1);
  while (q--) {
    long long x;
    cin >> x;
    cout << mid[x] << "\n";
  }
  return 0;
}
