CF1548B Integers Have Friends

Description

British mathematician John Littlewood once said about Indian mathematician Srinivasa Ramanujan that "every positive integer was one of his personal friends." It turns out that positive integers can also be friends with each other! You are given an array $ a $ of distinct positive integers. Define a subarray $ a_i, a_{i+1}, \ldots, a_j $ to be a friend group if and only if there exists an integer $ m \ge 2 $ such that $ a_i \bmod m = a_{i+1} \bmod m = \ldots = a_j \bmod m $ , where $ x \bmod y $ denotes the remainder when $ x $ is divided by $ y $ . Your friend Gregor wants to know the size of the largest friend group in $ a $ .

Input Format

N/A

Output Format

N/A

Explanation/Hint

In the first test case, the array is $ [1,5,2,4,6] $ . The largest friend group is $ [2,4,6] $ , since all those numbers are congruent to $ 0 $ modulo $ 2 $ , so $ m=2 $ . In the second test case, the array is $ [8,2,5,10] $ . The largest friend group is $ [8,2,5] $ , since all those numbers are congruent to $ 2 $ modulo $ 3 $ , so $ m=3 $ . In the third case, the largest friend group is $ [1000,2000] $ . There are clearly many possible values of $ m $ that work.