#include <stdio.h>
#include<stdlib.h>
int
main ()
{
  int N, Q;
  scanf ("%i %i", &N, &Q);
  int A[N], B[Q];
  
  for (int i = 0; i < N; i++)
    scanf ("%i", &A[i]);
  
  for (int i = 0; i < Q-1; i++)
    scanf ("%i ", &B[i]);
    
  for(int i=0; i<N-1; i++){
      for(int j = i+1; j<N; j++){
          if(A[j]<A[i]){
              int b=A[i];
              A[i]=A[j];
              A[j]=b;}
      }}
  int mA=A[N/2];
  int d=0;
  int j = (N/2)+1;
  int k=1;
  int counter=0;
  for(int i = 0; i < Q; i++){
      if(B[i]==mA) printf("%i\n", d);
      else{
          if (A[j]==B[i]){
              d=k;
              printf("%i\n", d);
              k+=2;
              j++;
          }
          else{
              for(i=j;i<N;i++){
                  j++;
                  counter++;
                  if (A[j]==B[i]){
                      d=k+counter*2;
                      printf("%i\n", d);}}
                  if(A[j]!=B[i]){
                      d=N;
                      printf("%i\n", d);}}
      
  }}
    
  return 0;
}