import itertools
import sys
 
f = sys.stdin 
t = int(f.readline().rstrip())
n = int(f.readline().rstrip())
a = [int(s) - 1 for s in itertools.islice(f.readline().split(), n)]
if t == 0:
  s = sum(a) % n
  sys.stdout.write(f'{s + 1}\n')
else:
  n += 1
  x = sum(a) % n
  t -= 1
  r = (t - x) % n
  if r < 0:
    r += n
  sys.stdout.write(f'{r + 1}\n')
sys.stdout.flush()
