Arithmetic Progression Subsequences (2)

Write a program that reads an integer n>1n>1 followed by a sequence of integers, and finds out whether the sequence contains a consecutive subsequence of length nn that forms an arithmetic progression.

A consecutive subsequence of integers forms an arithmetic progression if the difference between two consecutive numbers equals a fixed integer value rr. For instance, 45674 5 6 7 is an arithmetic progression with r=1r = 1, and 223344556622 33 44 55 66 is an arithmetic progression with r=11r = 11.

If the input sequence contains such a progression, the program must report the start number and the value rr. Otherwise, the program must indicate "No arithmetic progression of length n found".

Input

The input is an integer n>1n>1, followed by a sequence of integers containing at least 2 elements.

Output

If a progression subsequence of length nn exists, the output is the first element of the subsequence and the value of rr. Otherwise, the output is "No arithmetic progression of length n found".

Problem information

Author: ProAl

Generation: 2026-01-25T16:57:37.367Z

© Jutge.org, 2006–2026.
https://jutge.org