#import <Foundation/Foundation.h>
#import <stdio.h>

int main(int argc, char **argv) {
  NSInteger total;
  NSInteger houses;
  scanf("%ld %ld", &total, &houses);
  NSMutableArray *distances = [[NSMutableArray alloc] initWithCapacity: houses];
  NSInteger diff = 0;
  NSInteger i = 0;
  for(i = 0; i < houses; i++) {
    NSInteger meter;
    scanf("%ld", &meter);
    [distances addObject: [NSNumber numberWithInteger: meter - diff]];
    diff += meter - diff;
  }
  diff = total - diff;
  [distances addObject: [NSNumber numberWithInteger: diff]];
  NSInteger minDistance = total;
  NSInteger firstPrev = diff + [(NSNumber *)[distances objectAtIndex: 0] integerValue];
  for(i = 0; i < houses; i++) {
    NSNumber *prev = (i == 0) ? [NSNumber numberWithInteger: firstPrev] : [distances objectAtIndex: i-1];
    NSNumber *next = [distances objectAtIndex: i+1];
    minDistance = MIN(minDistance, MIN(total - next.integerValue, total - prev.integerValue));
  }
  
  printf("%ld", minDistance);
  return 0;
}