print((function (f, g, _, s) return f(g(s)) end)(function (a) local r = 0 for i=1,#a-1 do local d=a[i+1]-a[i] if d>0 and (r==0 or d0 and r or 0 end, function (s) local a = {} for e in s:gmatch("%d+") do table.insert(a,tonumber(e)) end table.sort(a) return a end, io.stdin:read("*l"), io.stdin:read("*l")))