#!/usr/bin/env perl use strict; use warnings; $_ = <>; my @v = split / /,<>; my %h; my $count = abs($v[0] - $v[1]); my $prev = -1; for my $x (@v) { $h{$x} = 1; if ($prev != -1 && abs($prev - $x) != $count) { print "NO\n"; exit; } $prev = $x; } my $size = int(keys %h); if ($size != @v) { print "NO\n"; exit; } print "YES\n";