def prog(n): a=n-1 b=n+1 c=a**2+b**2+n**2 d=c-2 d=d%3 return(d)