n=int(input()) a=list(map(int,input().split())) s=set() bool1=False bool2=False for i in a: s.add(i) if i%2: bool1=True else: bool2=True if len(s)==1: print(0) elif len(s)==2: print(max(s)-min(s)) elif bool1 and bool2: print(1) else: print(2)