#K81787. Longest Strictly Increasing Arithmetic Subsequence

    ID: 35831 Type: Default 1000ms 256MiB

Longest Strictly Increasing Arithmetic Subsequence

Longest Strictly Increasing Arithmetic Subsequence

Given a sequence of integers, find the length of the longest strictly increasing arithmetic subsequence. An arithmetic sequence is one in which the difference between consecutive elements is constant. In this problem, the subsequence (which need not be contiguous) must have a positive common difference, ensuring it is strictly increasing.

Input Format: The first line contains an integer (n), representing the number of elements. The second line contains (n) space-separated integers.

Output Format: Output a single integer denoting the length of the longest strictly increasing arithmetic subsequence.

inputFormat

The input is given via standard input (stdin). The first line contains an integer (n) (the number of elements). The second line contains (n) space-separated integers.

outputFormat

Print a single integer to standard output (stdout): the length of the longest strictly increasing arithmetic subsequence.## sample

7
3 6 9 12 15 1 4
5