CF889E Mod Mod Mod
Description
You are given a sequence of integers $ a_{1},a_{2},...,a_{n} $ . Let , and  for $ 1
Input Format
The first line contains a single integer $ n $ ( $ 1
Output Format
Output a single integer — the maximum value of $ f(x,1) $ over all nonnegative integers $ x $ .
Explanation/Hint
In the first example you can choose, for example, $ x=19 $ .
In the second example you can choose, for example, $ x=3 $ or $ x=2 $ .