// @ts-check

read(function(err, input) {
  var p = input.split('\n')[1]
    .split(' ')
    .map(function (v) { return Number(v); });

  var ok = trySort(p);
  console.log(ok ? 'YES' : 'NO');
});

/**
 * @param {(err: Error | null, input?: string) => void} callback
 */
function read (callback) {
  var input = '';
  process.stdin.setEncoding('utf8');
  process.stdin.on('readable', () => {
    /** @type {string | Buffer} */
    var chunk;
    while ((chunk = process.stdin.read()) !== null) {
      input += chunk;
    }
  });

  process.stdin.on('end', () => {
    callback(null, input);
  });
  process.stdin.on('error', () => {
    var error = new Error('Failed to read from stdin');
    callback(error);
  });
}

/**
 * @param {number[]} p
 * @returns {boolean}
 */
function trySort(p) {
  var numSwapped = 0;
  var maxSwapped = 1;

  for (let i = 0; i + 1 < p.length; i++) {
    for (let j = i + 1; j < p.length; j++) {
      var p1 = p[j];
      var p2 = p[j + 1];
      if (p1 > p2) {
        numSwapped += 1;
        if (numSwapped > maxSwapped) {
          return false;
        }

        p[j + 1] = p1;
        p[j] = p2;
      }
    }
  }

  return true;
}
