#include <stdio.h>
#include <stdlib.h>

int main() {
  int n;
  int q;
  scanf("%d %d", &n, &q);
  int* a;
  int* b;

  a = (int*)malloc(n*sizeof(int));
  b = (int*)malloc(q*sizeof(int));

  for(int i = 0; i < n; i++)
    scanf("%d", &a[i]);
  for(int i = 0; i < q; i++)
    scanf("%d", &b[i]);

  
  for(int i = 0; i < q; i++){
    int ind = -1;
    int counter = 0;
    for(int j = 0; j < n; j++){
      if(b[i] == a[j])
        ind = j;
      }
    if(ind == -1){
      if(n%2==0) 
        printf("%d\n", n-1);
      else
        printf("%d\n", n);
    }
    else if(ind+1 == n/2)
      printf("0\n");
    else {
      while(ind != (n + counter)/2)
        counter++;
      printf("%d\n", counter);
      }
    }
  }