/*
  AOJ 1017
  Title:Riffle Shuffle
  @kankichi573
*/
#include <stdio.h>
#include <string.h>
#define max(x,y) (((x)>(y))?(x):(y))
#define min(x,y) (((x)<(y))?(x):(y))

int carsd[50];
int op[50];
int N;

void shuffle(int cards[],int c)
{
  int outcards[50];
  int f,l,i,*p,*p1,*p2,s,center,siz;

  center=f=(N-1)/2;
  l=N-f;
  p=outcards;
  p1=cards;
  p2=cards+center;
  while(1)
    {
      siz=min(c,l);
      memcpy(p,p2,sizeof(int)*siz);
      l -= siz;
      if(f==0 && l==0)
	break;
      p+=siz;p2+=siz;

      siz=min(c,f);
      memcpy(p,p1,sizeof(int)*siz);
      f -= siz;
      if(f==0 && l==0)
	break;
      p+=siz;p1+=siz;
      
    }
  
  memcpy(cards,outcards,sizeof(int)*N);
}
dump(int cards[])
{
  int i;

  for(i=0;i<N;i++)
    printf("%d ",cards[i]);
  printf("\n");
}
main()
{
  int r,i;
  int cards[50];

  while(EOF!=scanf("%d %d",&N,&r))
    {
      
      for(i=0;i<r;i++)
	scanf("%d",&op[i]);
      for(i=0;i<N;i++)
	cards[i]=i;
      for(i=0;i<r;i++)
	shuffle(cards,op[i]);
      //dump(cards);
      printf("%d\n",cards[N-1]);
    }
  return(0);
}