#C10252. Arithmetic Progression Check
Arithmetic Progression Check
Arithmetic Progression Check
Given a sequence of integers, determine whether the sequence forms an arithmetic progression.
An arithmetic progression is a sequence where the difference between any two consecutive terms is constant. The formula for the nth term is given by: \( a_n = a_1 + (n-1)d \), where \( d \) is the common difference.
If the sequence contains fewer than 2 elements, output "NO".
inputFormat
The input is given via standard input (stdin). The first line contains a single integer ( n ) indicating the number of elements in the sequence. The second line contains ( n ) space-separated integers representing the sequence.
outputFormat
Output a single line to standard output (stdout): "YES" if the sequence is an arithmetic progression, otherwise "NO".## sample
5
3 6 9 12 15
YES