var lines = []; var reader = require('readline').createInterface({ input: process.stdin, output: process.stdout }); var counter = 0; reader.on('line', function (line) { counter += 1; lines.push(line); if( counter == 2){ main(); process.exit(0); } }); process.stdin.on('end', function () { }); function main(){ var n = parseInt(lines[0]); var xs = []; lines[1].split(" ").map(function(x) { xs.push(parseInt(x)); }); xs.sort(function(a,b){ if(a < b) return -1; if(a > b) return 1; return 0; }); var sa = xs[1] - xs[0]; if(sa == 0){ console.log("NO"); return 0; } for(var i = 1; i < n - 1; ++i){ if(sa != xs[i + 1] - xs[i]){ console.log("NO"); return 0; }else{ console.log("YES"); return 0; } } }