#include <bits/stdc++.h>
using namespace std;
vector<int> p[300100];
int per[300300];
long long sz[300300];
long long mx[300300];
int res[300300];
long long dfs(int x) {
  sz[x]++;
  for (int i = 0; i < p[x].size(); i++) {
    long long t = dfs(p[x][i]);
    sz[x] += t;
    mx[x] = max(mx[x], t);
  }
  return sz[x];
}
bool ch(int x, int y) {
  if (mx[y] * 2 > sz[x]) return 0;
  if ((sz[x] - sz[y]) * 2 > sz[x]) return 0;
  return 1;
}
void f(int x) {
  int st = x, maxx = 0;
  if (ch(x, x)) res[x] = x;
  for (int i = 0; i < p[x].size(); i++) {
    f(p[x][i]);
    if (maxx < sz[p[x][i]]) {
      maxx = sz[p[x][i]];
      st = res[p[x][i]];
    }
  }
  while (1) {
    if (ch(x, st)) {
      res[x] = st;
      break;
    }
    st = per[st];
  }
}
int main() {
  int n, q, z;
  cin >> n >> q;
  for (int i = 2; i <= n; i++) {
    scanf("%d", &z);
    per[i] = z;
    p[z].push_back(i);
  }
  dfs(1);
  f(1);
  for (int i = 0; i < q; i++) {
    scanf("%d", &z);
    printf("%d\n", res[z]);
  }
  return 0;
}
