# import pypyjit # pypyjit.set_param('max_unroll_recursion=-1') from collections import * from functools import * from itertools import * from heapq import * import sys,math input = sys.stdin.readline N = int(input()) T = int(input()) A = list(map(int,input().split())) X = defaultdict(int) M = 10**5+5 called = [0]*M called[A[0]]=1 for i in range(N-1): target = [] for j in range(M): if called[j]==i+1: target.append((X[j],j)) target.sort() n = len(target) a = A[i+1] for x,j in target: if j+a