jiahuimbzuai/CoQuIR huggingface dataset:
//  [java]
import java.util.*;
import java.util.stream.LongStream;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int n = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).sum();
        System.out.println(n >= 22 ? "bust" : "win");
    }

}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);	
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9+7;
const ll 	N 		= 	2*1e6;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

// <------------- Declare Variables Here ------------> //

ll T=1;
ll n,x,y,m;
string s,t;
vll a;
// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	ll a,b,c;
	cin>>a>>b>>c;
	if(a+b+c>=22) {
		cout<<"bust";
	}
	else {
		cout<<"win";
	}
}

int main() {
	fastio;randomINT;
	//cin>>T;
	while(T--) {
		MAIN();
	}
	return 0;
}
//  [cpp]
#include <bits/stdc++.h>
#include <boost/foreach.hpp>
using namespace std;
#define pi 2*asin(1.0)
#define MAX 10000000
#define MOD 1000000007
#define _GLIBCXX_DEBUG
 
vector<long> fac(MAX);
vector<long> finv(MAX);
vector<long> inv(MAX);
 
//template functions
/////////////////////////
void Cominit(){
  fac.at(0)=fac.at(1)=1;
  finv.at(0)=finv.at(1)=1;
  inv.at(1)=1;
  for(long i=2;i<MAX;i++){
      fac.at(i)=(fac.at(i-1)*i)%MOD;
      inv.at(i)=MOD-inv.at(MOD%i)*(MOD/i)%MOD;
      finv.at(i)=finv.at(i-1)*inv.at(i)%MOD;
  }
}

long facComb(long N,long M){// nCm%
if(N<M) return 0;
if(N<0||M<0) return 0;
return fac.at(N)*(finv.at(M)*finv.at(N-M)%MOD)%MOD;
}

long Comb(long N,long M){// nCm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
for(long i=M;i>0;i--){
    ans=ans/i;
}
return ans;
}

long Perm(long N,long M){// nPm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
return ans;
}

long GCM(long A,long B){
            long W,r;
    if(A<B){

        W=B;
        B=A;
        A=W;
    }
    while(A%B!=0){
        r=A%B;
        A=B;
        B=r;
    }
    return B;
}
long LCM(long A,long B){
    return (A*B)/GCM(A,B);
}

long upDiv(long a,long b){
  return (a+b-1)/b;
}

long strtolong(string str){
istringstream ss;
ss=istringstream(str);
long num;
ss>>num;
return num;
}

long chartolong(char ch){
long num;
num=ch-'0';
return num;
}

string longtostr(long N){
    string str;
    str=to_string(N);
    return str;
}









/////////////////////////


//Answer


int main() {

long A,B,C;
cin>>A>>B>>C;
if(A+B+C<=21){
cout<<"win"<<endl;
}else{
cout<<"bust"<<endl;
}

}
//  [cpp]
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;

int main(){
    int a, b, c;
    cin>>a>>b>>c;
    if(a+b+c >= 22) cout<<"bust\n";
    else cout<<"win\n";
}
//  [c]
#include<stdio.h>
#include<string.h>
 
 
int main(){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if(a+b+c<22)
  printf("win");
  else
    printf("bust");
  return 0;
}
//  [c]
#include <stdio.h>
//#include <string.h>

int main(void){
  int a1,a2,a3;
  scanf("%d %d %d", &a1, &a2, &a3);
  //scanf("%d", &b);

  if(a1+a2+a3>21)
    printf("bust");
  else
    printf("win");
  
  //printf("%d", 6-a-b);

  return 0;
}
//  [c]
#include <stdio.h>


int main()
{
	int A1, A2, A3;
	
	scanf("%d %d %d", &A1, &A2, &A3);
	(A1 + A2 + A3 >= 22) ? puts("bust") : puts("win");
	
	
	return 0;
}
//  [javascript]


function Main(input) {
  input = input.split("\n");
  var A1 = parseInt(input[0].split(" ")[0]);
  var A2 = parseInt(input[0].split(" ")[1]);
  var A3 = parseInt(input[0].split(" ")[2]);
  if(A1+A2+A3>=22){
    var ans ="bust";
  }else{
    var ans ="win";
  }

  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}

function Main(input) {
  input = myconv(input,4);
  if(input[0] + input[1] + input[2] <= 21){
     myout("win");
     }else{
     myout("bust");
     }
}

Main(myin());
//  [javascript]
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	tmp = input[0].split(" ");
	//文字列から10進数に変換するときはparseIntを使います
	var a = parseInt(tmp[0], 10);
	var b = parseInt(tmp[1], 10);
	var c = parseInt(tmp[2], 10);
	if(a+b+c >= 22){
       console.log('bust');
    }else{
       console.log('win');
    }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [go]
package main

import (
	"fmt"
)

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	ans := a + b + c

	if ans >= 22 {
		fmt.Println("bust")
	} else {
		fmt.Println("win")
	}
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	limit := 22

	for i := 0; i < 3; i++ {
		scanner.Scan()
		target, err := strconv.Atoi(scanner.Text())
		if err != nil {
			log.Fatal(err)
		}
		limit -= target

		if limit <= 0 {
			fmt.Println("bust")
			os.Exit(0)
		}
	}

	fmt.Println("win")
}
//  [ruby]
puts gets.split.map(&:to_i).inject(:+) > 21 ? "bust" : "win"
//  [ruby]
arr = gets.chomp.split(' ').map(&:to_i)
if arr.sum >= 22
  puts "bust"
else
  puts "win"
end
//  [ruby]
puts gets.split.map(&:to_i).inject(:+) >= 22 ? 'bust' : 'win'
//  [rust]
use proconio::input;

fn main() {
    input! {
        a: [u16; 3]
    }

    solve(&a);
}

fn solve(a: &[u16]) {
    let sum = a.iter().fold(0, |s, x| s + x);
    match sum.cmp(&22) {
        std::cmp::Ordering::Less => println!("win"),
        _ => println!("bust"),
    }
}
//  [rust]
#[allow(unused_imports)]
use proconio::{fastout, input, marker::*};

#[fastout]
fn main() {
    input! {
        a: [usize; 3],
    }

    println!("{}", if 22 <= a.iter().sum::<usize>() { "bust" } else { "win" });
}
//  [swift]
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func main() {
    let aaa = readInts()
    if aaa[0] + aaa[1] + aaa[2] >= 22 {
        print("bust")
    } else {
        print("win")
    }
}

main()
//  [swift]
let arr=readLine()!.characters.split{$0==" "}.map{Int(String($0))!}

if (arr[0] + arr[1] + arr[2]) >= 22 {
  print( "bust" )
} else {
  print( "win" )
}
//  [swift]
//
//  A.swift
//  AtCoder
//
//  Created by NakaiKoheiSub on 2020/07/14.
//  Copyright © 2020 NakaiKoheiSub. All rights reserved.
//

import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}
func main() {
    let As = readInts()
    if As.reduce(0){$0+$1} < 22{
        print("win")
    }else{
        print("bust")
    }
    
}
main()
//  [typescript]
"use strict";

function compareFunc(a, b) {
  return a - b;
}
const main = arg => {
  const input = arg.trim().split("\n");
  const T = input[0].split(" ").map(x => parseInt(x)).reduce((a, v) => a + v);
  if (T >= 22) {
    console.log("bust");
  } else {
    console.log("win");
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
function main(input) {
  const [a,b,c] = input.split(" ")
  
  if(parseInt(a) + parseInt(b) + parseInt(c) < 22){
  	return console.log("win")
  }else{
    return console.log("bust")
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
export class Main {
  static main(input: string): string {
    const tmp: string[] = input.split("\n");
    const [a, b, c]: number[] = tmp.shift().split(" ").map(int => parseInt(int));
    return `${a + b + c <= 21 ? "win" : "bust"}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));
//  [python]
import numpy as np
N = int(input())
A = list(map(int, input().split()))
B = np.zeros(N+1)

for i in range(N):
  B[A[i]]+=1
#print(B)

all_c = 0
for i in range(1,N+1):
  all_c += int(B[i]*(B[i]-1)/2)			# 同一の整数を持つボールの組合せ数
for i in range(N):
  if B[A[i]] != 0:
    print(int(all_c-(B[A[i]]-1)))
//  [python]
import numpy as np


def main():
    N = int(input())
    A = [int(x) for x in input().split()]

    from collections import Counter

    c = Counter(A)

    num = {x: n*(n-1)//2 for x, n in c.items()}
    tot = sum(num.values())

    for x in A:
        n = c[x] - 1
        ans = tot - num[x] + n*(n-1)//2
        print(ans)


if __name__ == '__main__':
    main()
//  [python]
import sys
from collections import Counter

def comb(n, r):
    if r > n:
        return 0
    r = min(r, n - r)
    if r == 0: return 1
    if r == 1: return n
    numerator = list(range(n-r+1, n+1))
    denominator = list(range(1, r+1))
    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
    return result

n, *a = map(int, sys.stdin.read().split())

def main():
    c = Counter(a)
    res = 0
    for v in c.values():
        res += comb(v, 2)

    for i in a:
        yield res - comb(c[i], 2) + comb(c[i]-1, 2)
        
if __name__ == "__main__":
    ans = main()
    print(*ans, sep='\n')
//  [java]
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		HashSet<Long> first = new HashSet<>();
		HashMap<Long, Long> map = new HashMap<>();

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] array = new long[n];
		for (int i = 0; i < n; i++) {
			long a = sc.nextInt();
			array[i] = a;
			if (first.contains(a)) {
				if (map.containsKey(a)) {
					long num = map.get(a);
					map.put(a, num + 1);
				} else {
					map.put(a, 2L);
				}
			} else {
				first.add(a);
			}
		}
		sc.close();

		long answer = 0;
		for (long value : map.values()) {
			long product = (value * (value - 1)) / 2;
			answer = answer + product;
		}

		for (int i = 0; i < n; i++) {
			long a = array[i];
			if (!map.containsKey(a)) {
				print(answer);
			} else {
				long dup = map.get(a);
				long subtractAns = answer - dup + 1;
				print(subtractAns);
			}
		}

	}

	public static void print(Object obj) {
		System.out.println(obj);
	}

}
//  [java]


import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        int arr[]=new int[n];
        HashMap<Integer,Integer> hashMap=new HashMap<>();
        HashMap<Integer,Long> ans=new HashMap<>();
        List<Integer> list=new ArrayList<>();
        HashSet<Integer> hashSet=new HashSet<>();
        for(int j=0;j<n;j++){
            arr[j]=scanner.nextInt();
            if(hashMap.get(arr[j])==null){
                hashMap.put(arr[j],1);
            }
            else{
                hashMap.put(arr[j],hashMap.get(arr[j])+1);
                if(!hashSet.contains(arr[j])) {
                    list.add(arr[j]);
                    hashSet.add(arr[j]);
                }
            }
        }
        long tot=0;
        for(int i=0;i<list.size();i++){

                //tot+=(long)((long)(hashMap.get(list.get(i))-1)*(long)(hashMap.get(list.get(i))-2))/(long)2;
                tot+=(long)((long)(hashMap.get(list.get(i))-1)*(long)(hashMap.get(list.get(i))))/(long)2;


        }
        for(int j=0;j<n;j++)
        {
            if(ans.get(arr[j])==null){
                long tott=0;
                if(hashMap.get(arr[j])==1){
                    tott=tot;
                }
                else {
                    tott = (long)tot - (long)((hashMap.get(arr[j]) - 1) * (hashMap.get(arr[j])))/2 +
                            (long)((hashMap.get(arr[j]) - 1) * (hashMap.get(arr[j])-2))/2 ;
                }
                ans.put(arr[j],tott);
                System.out.println(tott);
            }
            else{
                System.out.println(ans.get(arr[j]));
            }
        }

    }
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;
const int MAX = 2e5 ;
const int INF = 1e9 + 1e5 + 2;
const int mod= 1e9+7;
using namespace std;
typedef long long ll;
bool cmp(const pair<int,int> &a,
               const pair<int,int> &b)
{
       if (a.first==b.first)
           return (a.second >b.second);
       return (a.first<b.first);
}
int main()
{
    ll n;

    cin>>n;

    vector<ll>v(n);

    for (ll i=0; i<n; ++i)
        cin>>v[i];

    map<ll,ll>m;
    for (ll i=0; i<n; ++i)
    {
        m[v[i]]++;
    }

    ll sum=0;
    for (ll i=1; i<=1000000; ++i)
    {
        ll p=1;
        p*=m[i]*(m[i]-1);

        sum+=p/2;
    }
    for (ll i=0; i<n; ++i)
    {
        ll ans=sum;
        ans-=m[v[i]]*(m[v[i]]-1)/2;

        ans+=(m[v[i]]-1)*(m[v[i]]-2)/2;

        cout<<ans<<"\n";
    }















}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;

int main() {
    long long n, i;
    cin >> n;
    map<long long, long long> lst;
    map<long long,long long> ans;
    map<long long,long long> min;
    map<long long,long long> nor;
    long long preans = 0;
    map<long long,long long> count;
    for(i = 1; i <= n; i++){
        min[i] = 0;
        nor[i] = 0;
    }
    for(i = 0; i < n; i++){
        cin >> lst[i];
    }
    for(i = 0; i < n; i++){
        if(count.count(lst[i])) count[lst[i]]++;
        else count[lst[i]] = 1;
    }
    for(auto k:count){
        auto key = k.first;
        auto val = k.second;
        nor[key] = val*(val-1)/2;
        min[key] = (val-1)*(val-2)/2;
    }
    for(i = 1; i <= n; i++){
        preans += nor[i];
    }
    for(i = 1; i <= n; i++){
        ans[i] = preans - nor[i] + min[i];
    }
    for(i = 1; i <= n; i++){
        cout << ans[lst[i-1]] << endl;
    }
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char* argv[]){
        char tmp[1024+1]={0};
        char *buf=NULL;
        char* p=NULL;
        int N=0;
        int *A=NULL;
        int *C=NULL;

        buf = (char*)calloc(200000+1, 7);
        if(fgets(buf, sizeof(buf)-1, stdin)==NULL){
                return 1;
        }
        N = atoi(buf);

        A = (int*)calloc(N+1, sizeof(int));
        C = (int*)calloc(N+2, sizeof(int));
        for(int i=0; i<N+1; i++){ C[i]=0; }

        memset(buf, 0, N*7+1);
        while(fgets(tmp, sizeof(tmp)-1, stdin)!=NULL){
                strcat(buf, tmp);
                memset(tmp, 0 , sizeof(tmp));
        }

        p = strtok(buf, " ");
        A[0] = atoi(p);
        C[A[0]]++;
        for(int i=1; i<N; i++){
                p = strtok(NULL, " ");
                A[i] = atoi(p);
                C[A[i]]++;
        }
        long long total=0;
        for(int i=1; i<N+1; i++){
                long long a = (long long)C[i];
                total += a*(a-1)/2;
        }
        for(int i=0; i<N; i++){
                long long v = (long long)C[A[i]];
                long long d = 0;
                if(v>1) {
                        d = v*(v-1)/2 - (v-1)*(v-2)/2;
                }
                long long ans = total - d;
                printf("%lld\n", ans);
        }
        return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char* argv[]){
        char tmp[1024+1]={0};
        char *buf=NULL;
        char* p=NULL;
        int N=0;
        int *A=NULL;
        int *C=NULL;

        buf = (char*)calloc(200000+1, 7);
        if(fgets(buf, sizeof(buf)-1, stdin)==NULL){
                return 1;
        }
        N = atoi(buf);

        A = (int*)calloc(N+1, sizeof(int));
        C = (int*)calloc(N+2, sizeof(int));
        for(int i=0; i<N+1; i++){ C[i]=0; }

        memset(buf, 0, N*7+1);
        while(fgets(tmp, sizeof(tmp)-1, stdin)!=NULL){
                strcat(buf, tmp);
                memset(tmp, 0 , sizeof(tmp));
        }

        p = strtok(buf, " ");
        A[0] = atoi(p);
        C[A[0]]++;
        for(int i=1; i<N; i++){
                p = strtok(NULL, " ");
                A[i] = atoi(p);
                C[A[i]]++;
        }
        long long total=0;
        for(int i=1; i<N+1; i++){
                long long a = (long long)C[i];
                total += a*(a-1)/2;
        }
        for(int i=0; i<N; i++){
                long long v = (long long)C[A[i]];
                long long d = 0;
                if(v>1) { d = v -1; }
                long long ans = total - d;
                printf("%lld\n", ans);
        }
        return 0;
}
//  [javascript]
"use strict";
const combi = function(n){
    return n*(n-1)/2
}

const main = arg => {
    const input = arg.trim().split("\n");

    const N = parseInt(input[0].split(" ")[0]);
    const A = input[1].split(" ").map(n => parseInt(n));

    let m = {}
    for(let i = 0; i<A.length; i++){
        if(!m[A[i]]) m[A[i]] = 1
        else m[A[i]]++
    }
    let orgCnt = 0
    let keys = Object.keys(m)
    for(let i = 0; i<keys.length; i++){
        let tmp = m[keys[i]]
        orgCnt = orgCnt + tmp * (tmp-1)/2
    }

    for(let i = 0; i<A.length; i++){
        let num = m[A[i]]
        const diff = num*(num-1)/2 - (num-1)*(num-2)/2
        console.log(orgCnt-diff)
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
// inputに入力データ全体が入る
function Main(input) {
  // 1行目がinput[0], 2行目がinput[1], …に入る
  input = input.split("\n");
  items = input[1].split(' ').map(v => parseInt(v, 10))
  data = new Map()
  for (var i = 0; i < items.length; i++) {
    if (data.has(items[i])) {
      data.set(items[i], data.get(items[i]) + 1)
    } else {
      data.set(items[i], 1)
    }
  }

  sum = 0
  for (j of data.values()) {
    sum += Math.floor(j * (j - 1) / 2)
  }
  //文字列から10進数に変換するときはparseIntを使います
  // const a = parseInt(input[0], 10);
  //出力
  for (i = 0; i < items.length; i++) {
    console.log(sum - (data.get(items[i]) - 1))
  }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
"use strict";
//const p = s => console.log(s);
let inp = require("fs").readFileSync("/dev/stdin", "utf8").trim();
let max = Number(inp.split('\n')[0]);
let nums = inp.split('\n')[1].split(' ').map(Number);
let formed_nums = (new Array(max)).fill(0);
//p(formed_nums)
for (let i = 0; i < max; i++) {
    formed_nums[nums[i] - 1]++
}
//p(formed_nums);
let sum = 0;
formed_nums.forEach(elm => {
    if (elm >= 2) {
        sum += elm * (elm - 1) / 2
    }
});
//p(nums)
nums.forEach(elm => {
    console.log(sum - formed_nums[elm - 1] + 1)
})
//  [go]
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}

	m := make(map[int]int) // 累積
	for _, v := range a {
		m[v]++
	}

	var total int
	for _, v := range m {
		total += v * (v - 1) / 2
	}

	for i, v := range a {
		if i != 0 {
			fmt.Println()
		}
		var cnt int
		w := m[v]
		cnt = total - w*(w-1)/2 + (w-1)*(w-2)/2
		fmt.Print(cnt)
	}
}
//  [go]
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	arr := make([]int, N)
	count := map[int]int{}
	result := map[int]int{}
	for i := 0; i < N; i++ {
		var a int
		fmt.Scan(&a)
		arr[i] = a
		count[a]++
	}
	for _, v := range arr {
		if res, ok := result[count[v]]; ok {
			fmt.Println(res)
			continue
		}
		var res int
		for i := 1; i <= N; i++ {
			var c int
			if i == v {
				c = count[i] - 1
			} else {
				c = count[i]
			}
			res += c * (c - 1) / 2
		}
		fmt.Println(res)
		result[count[v]] = res
	}
}
//  [go]
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	A := make([]int, N)
	m := make(map[int]int)
	for i := range A {
		fmt.Scan(&A[i])
		m[A[i]]++
	}
	total := 0
	for _, c := range m {
		total += c * (c - 1) / 2
	}
	for i := 0; i < N; i++ {
		fmt.Println(total - (m[A[i]] - 1))
	}
}
//  [ruby]
# abc159 D
n = gets.to_i
a = gets.split.map(&:to_i)

agroup = {}

a.group_by(&:itself).each{|k,v| agroup[k] = v.size  }

# p agroup

agroup2 = {}
agroup.each { |key, val|
  agroup2[key] = val * (val-1) / 2
}
sum = agroup2.map{|k,v|v}.inject(:+)

# puts "sum: #{sum}"

a.each do |aa|
  val = agroup[aa]
  p sum - ( val * (val-1) / 2 )  + ( (val-1) * (val-2) / 2 )
end
//  [ruby]
def solve
  n = gets.to_i
  arr = gets.split.map!(&:to_i)
  arr_grouped_by = arr.group_by(&:itself).map { |key, value| [key, value.count] }.to_h
  total_value = arr_grouped_by.map { |key, value| (value * (value - 1)) / 2 }.inject(&:+)
  n.times do |i|
    index = arr[i]
    total_value_v2 = total_value
    arr_grouped_by[index] = arr_grouped_by[index] - 1
    p total_value_v2 - arr_grouped_by[index]
    arr_grouped_by[index] = arr_grouped_by[index] + 1
  end
end
solve
//  [ruby]
n = gets.to_i
a = gets.split.map(&:to_i)
h = a.group_by(&:itself).map{|k,v| [k, v.count]}.to_h
total = h.values.map{|i| i*(i-1)/2}.inject(:+)

a.each{|ai|
  hi = h[ai]
  p hi==1 ? total : total - hi*(hi-1)/2 + (hi-1)*(hi-2)/2
}
//  [rust]
use std::collections::*;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let a: Vec<i32> = sc.vec(n);
    let mut count: BTreeMap<i32, i64> = BTreeMap::new();
    for i in 0..n {
        *count.entry(a[i]).or_insert(0) += 1;
    }
    let mut base: i64 = 0;
    for (_key, value) in count.iter() {
        base += value * (value - 1) / 2;
    }
    for e in a.iter() {
        println!("{}", base - count[e] + 1);
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
//  [typescript]
function main(input) {
  const inputs =input.split('\n')
  const [N] = inputs[0].split(' ').map(Number)
  const A = inputs[1].split(' ').map(Number)

  const count = []
  for(let i = 0; i < N; i++) {
    if (count[A[i]] === undefined) {
      count[A[i]] = 0
    }
    count[A[i]] = count[A[i]] + 1
    // console.log(count)
  }

  // console.log(count)
  let all = 0
  for(let i = 1; i <= count.length - 1; i++) {
    if (count[i] === undefined) continue
    all += count[i] * (count[i] - 1) / 2
  }

  for (let i = 0; i < N; i++) {
    const diff = count[A[i]] * (count[A[i]] - 1) / 2 - ((count[A[i]] - 1) * (count[A[i]] - 2) / 2)
    console.log(all - diff)
  }

}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))
//  [typescript]
class NormalInput {
  input: string[];
  pointer: number;
  constructor(raw: string) {
    this.input = raw.split(/ |\n/);
    this.pointer = 0;
  }
  int = (): number => {
    const ret = parseInt(this.input[this.pointer], 10);
    this.pointer++;
    return ret;
  };
  str = (): string => {
    const ret = this.input[this.pointer];
    this.pointer++;
    return ret;
  };
  strs = (length: number): string[] => {
    let ret: string[] = [];
    for (let i = 0; i < length; i++) {
      ret.push(this.str());
    }
    return ret;
  };
  ints = (length: number): number[] => {
    let ret: number[] = [];
    for (let i = 0; i < length; i++) {
      ret.push(this.int());
    }
    return ret;
  };
}
function rep(n: number) {
  let a = [];
  for (let i = 0; i < n; i++) a.push(i);
  return a;
}
function Main({ int, str, strs, ints }: NormalInput) {
  const N = int();
  const A = ints(N);
  const count = [];
  A.forEach(a => {
    if (!count[a]) count[a] = 0;
    count[a] = count[a] + 1;
  });
  let sum = 0;
  count.forEach(i => {
    if (i) {
      sum += (i * (i - 1)) / 2;
    }
  });
  // rep(count.length).forEach(i => console.log(i, count[i]));
  // console.log(sum);
  rep(N).forEach(i => {
    let x = count[A[i]];
    console.log(sum - (x * (x - 1)) / 2 + ((x - 1) * (x - 2)) / 2);
  });
}

//DO NOT EDIT
Main(new NormalInput(require("fs").readFileSync("/dev/stdin", "utf8")));
//  [python]
import numpy as np

N = int(input())
p = np.array(input().split(), dtype=np.int64)

q1 = np.sort(p)

q2 = q1 - p

if np.sum(q2 != 0) == 0 or np.sum(q2 != 0) == 2:
    print("YES")
else:
    print("NO")
//  [python]
import numpy as np
n = int(input())

P = [int(s) for s in input().split()]

K = [int(i+1) for i in range(n)]

P = np.array(P)
K = np.array(K)
P_K = P - K

c = 0
for i in range(n):
    if P_K[i] != 0:
        c += 1
    else:
        pass
if c <= 2:
    print("YES")
else:
    print("NO")
//  [python]
# -*- coding: utf-8 -*-
import numpy as np

n = int(input())
p = list(map(int, input().split()))

p_ori = p[:]

p.sort()
p_sorted = p[:]

if p_ori == p_sorted:
    print("YES")
else:
    p_ori = np.array(p_ori)
    p_sorted = np.array(p_sorted)
    p_diff = p_ori - p_sorted

    if(sum(p_diff != 0) == 2):
        if p_diff.sum() == 0:
            print("YES")
        else:
            print("NO")
    else:
        print("NO")
//  [java]
	import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;
 
public class Main {
 
	public Main() {
		// TODO 自動生成されたコンストラクター・スタブ
	}
 
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Map <Integer,Integer> mapP = new HashMap<Integer,Integer> ();
		Map <Integer,Integer> mapS = new TreeMap<Integer,Integer> ();
			// 整数の入力
			int n,p,q,a,b;
			int index,counter,result;
			n = sc.nextInt();
			for(index=0;index<n;index++) {
				p = sc.nextInt();
				mapP.put(index,p);
				mapS.put(p,index);
			}
			sc.close();
			
			result=0;
			counter=0;
			for(Integer s: mapS.keySet()) {
				index=mapS.get(s);
				p=mapP.get(index);
				if(counter!=index) {
					result++;
				}
				counter++;
			}
			if(result==0 || result==2) {
				System.out.print("YES");
			}
			else {
				System.out.print("NO");
			}
			
 
			// 出力
 
	}
}
//  [java]
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author teiwa
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            //List<Integer> list = new ArrayList<>();
            int[] array = new int[N];
            for (int i = 0; i < N; i++) {
                array[i] = in.nextInt();
            }
            //List<Integer> answerList = list.stream().sorted().collect(Collectors.toList());
            int[] answerArray = Arrays.stream(array).sorted().toArray();
            int[] swapArray = Arrays.copyOf(array, N);

            if (Arrays.equals(answerArray, swapArray)) {
                out.println("YES");
                return;
            }

            for (int i = 0; i < N; i++) {
                int tmpNum = array[i];
                for (int j = i + 1; j < N; j++) {
                    swapArray[i] = swapArray[j];
                    swapArray[j] = tmpNum;
                    if (Arrays.equals(answerArray, swapArray)) {
                        out.println("YES");
                        return;
                    }
                    swapArray[j] = swapArray[i];
                    swapArray[i] = tmpNum;
                }
            }
            //System.out.println("NO");
            out.println("NO");
        }

    }
}
//  [java]
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.nextLine());
		int[] p = Arrays.stream(sc.nextLine().split(" ")).mapToInt(s -> Integer.parseInt(s)).toArray();

		int miss = 0;
		for (int i = 0; i < N; i++) {
			if (p[i] != i + 1) {
				miss += 1;
			}
		}
		if (miss == 0 || miss == 2) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}
//  [cpp]
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;

int main(){
  int N;
  ll p[100000];
  cin>>N; 
  for (int i(0);i<N;i++) cin>>p[i];
      bool finishi(true);
      for (int k(1);k<N;k++){
   //     cerr << p[k-1]<<" "<<p[k]<<endl;
        if (p[k-1]>p[k]) finishi=false;
      }
      if (finishi==true){
        cout << "YES" << endl;
        return 0;
      }
  for (int i(0);i<N;i++){
    for (int j(i+1);j<N;j++){
      int s[100];
      for (int k(0);k<N;k++){
        s[k]=p[k];
        cerr << s[i] << " "<< p[i]<<endl;
      }
      int tmp; 
      tmp=s[i];
      s[i]=s[j];
      s[j]=tmp;
      bool finish(true);
      for (int k(1);k<N;k++){
//         cerr << s[k-1]<<" "<<s[k]<<endl;
        if (s[k-1]>s[k]) finish=false;
      }
      cerr << endl;
      if (finish==true){
        cout << "YES" << endl;
        return 0;
      }
    }
  }
  cout << "NO" << endl;
  return 0;
}
//  [c]
#include<stdio.h>
int main(void)
{
	int N,p[51],i;
	int cnt=0;
	scanf("%d",&N);
	for(i=0;i<N;i++)
	{
		scanf("%d",&p[i]);

	}
	for(i=0;i<N;i++)
	{
		if(i!=p[i]-1)
		{
			cnt++;
		}
		if(cnt>2)
		break;
	}
	if(cnt>2)
	printf("NO");
	else
	printf("YES");
	return 0;
}
//  [c]
#include<stdio.h>

int main()
{
int n,a[50],s[50],i,c=0;
scanf("%d",&n);

for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    }
for(i=0;i<n;i++){
    if(a[i]!=i+1){
        c++;
        }
    }
if(c>2){
    printf("NO");
    }
else
    printf("YES");

return 0;
}
//  [c]
#include<stdio.h>

int main()
{
    int N, a=0, b=0, i, bucket;
    scanf("%d", &N);
    int arr[N], arr2[N];

    for(i=0; i<N; i++)
    {
        scanf("%d", &arr[i]);
    }
    for(i=0; i<N-1; i++)
    {
        if(arr[i+1]<arr[i])
        {
            if(a==0)arr2[a] = i;
            else arr2[a] = i+1;
            a++;
        }
    }
    if(a==0)printf("YES");
    else if(a==2)
    {
        bucket = arr[arr2[0]];
        arr[arr2[0]] = arr[arr2[1]];
        arr[arr2[1]] = bucket;

        for(i=0; i<N-1; i++)
        {
            if(arr[i+1]<arr[i])
            {
                b++;
                break;
            }
        }
        if(b==0)printf("YES");
        else printf("NO");
    }
    else printf("NO");

    return 0;
}
//  [javascript]
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = new Date();
  Main();
  var end = new Date() - start;
  
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}


//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var N = nextInt();
	var list = nextIntArray();
	var check = JSON.parse(JSON.stringify(list));
	check.sort(function(a,b){
		return a - b;
	});
	if(myconv(list, 8) == myconv(check, 8)){
		myout("YES");
		return;
	}
	for(var i = 0; i < N - 1; i++){
		for(var j = i + 1; j < N; j++){
			var sw = JSON.parse(JSON.stringify(list));
			var tmp = sw[i];
			sw[i] = sw[j];
			sw[j] = tmp;
			if(myconv(sw, 8) == myconv(check, 8)){
				myout("YES");
				return;
			}
		}
	}
	myout("NO");
}
//  [javascript]
"use strict";
function main(input) {
    const line = input.split("\n");
    const N = parseInt(line[0]);
    const p = line[1].split(" ").map(Number);
    let cnt = 0;
    for (let i = 0; i < N; i++) if (p[i] !== i + 1) cnt++;
    console.log(cnt <= 2 ? "YES" : "NO");
    return;
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var (
	BufferSize = 10 * 10 * 10 * 10 * 10 * 10 * 10
)

func scanStr(sc *bufio.Scanner) string {
	if !sc.Scan() {
		panic(nil)
	}

	return sc.Text()
}

func scanInt(sc *bufio.Scanner) int {
	if !sc.Scan() {
		panic(nil)
	}

	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, BufferSize)
	sc.Split(bufio.ScanWords)

	n := scanInt(sc)
	l := make([]int, n, n)
	p := make([]int, n, n)
	m := make([]int, 0, n)

	for i := 0; i < n; i++ {
		l[i] = scanInt(sc)
		p[i] = l[i]
	}
	sort.Ints(p)

	for i := 0; i < n; i++ {
		if l[i] != p[i] {
			m = append(m, i)
			if len(m) > 2 {
				fmt.Printf("NO\n")
				return
			}
		}
	}

	fmt.Printf("YES\n")
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024*1024), bufio.MaxScanTokenSize)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func main() {
	N := nextInt()
	S := make([]int, N)
	for i := 0; i < N; i++ {
		n := nextInt()
		S[i] = n
	}
	if IsAsc(S) {
		fmt.Println("YES")
		return
	}
	for i := 0; i < N-1; i++ {
		for j := i + 1; j < N; j++ {
			swp := swap(i, j, S)
			if IsAsc(swp) {
				fmt.Println("YES")
				return
			}
		}
	}
	fmt.Println("NO")
	return
}

func IsAsc(S []int) bool {
	for i := 0; i < len(S)-1; i++ {
		if S[i] > S[i+1] {
			return false
		}
	}
	return true
}

func swap(a, b int, S []int) []int {
	ret := make([]int, len(S))
	for i := 0; i < len(S); i++ {
		ret[i] = S[i]
		if i == a {
			ret[i] = S[b]
		} else if i == b {
			ret[i] = S[a]
		}
	}
	return ret
}
//  [ruby]
input = readlines()

n = input.shift.chomp.to_i
list = input.shift.chomp.split("\s").map{|x| x.to_i}

if list.join('') == list.sort().join('')
  puts 'YES'
  exit()
end

list.each_with_index do |l1, i1|
  list.each_with_index do |l2, i2|
    next if i1 == i2
    tmp = list.clone
    tmp[i1] = list[i2]
    tmp[i2] = list[i1]
    if tmp.join('') == tmp.sort().join('')
      puts 'YES'
      exit()
    end
  end
end

puts 'NO'
//  [ruby]
n,*a=`dd`.split.map &:to_i
t=(1..n).count{a[_1-1]!=_1}
puts t>2 ? :NO : :YES
//  [ruby]
n,*a=`dd`.split.map(&:to_i)
b=a.sort
c=0
n.times do |i|
  c+=1 if a[i]!=b[i]
  if c>2
    puts 'NO'
    exit
  end
end
puts 'YES'
//  [rust]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        p: [usize; n]
    };

    let p: Vec<usize> = p;

    let mut p_clone = p.clone();
    p_clone.sort();

    let mut count = 0;

    for (i, j) in p.iter().zip(p_clone.iter()) {
        if i != j {
            count += 1;

            if count > 2 {
                break;
            }
        }
    }

    if count > 2 {
        println!("NO");
    } else {
        println!("YES");
    }
}
//  [rust]
use proconio::input;

fn main() {
    input! {
        n: i32,
        p: [i32; n],
    }

    solve(&p);
}

fn solve(p: &[i32]) {
    let mut cnt = 0;
    for i in 0..p.len() {
        if !(i as i32 + 1 == p[i]) {
            cnt += 1;
        }

        if cnt > 2 {
            println!("NO");
            return;
        }
    }

    println!("YES");
}
//  [rust]
#[allow(unused_imports)]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(n: usize, mut p: [usize; n]);
    let pp = p.clone();
    p.sort();

    let mut count = 0_usize;
    for i in 0..n {
        if p[i] != pp[i] {
            count += 1;
        }
    }

    println!("{}", if count <= 2 { "YES" } else { "NO" });
}
//  [swift]
import Foundation

let n = Int(readLine()!)!
let inputString = readLine()!

var split: [Int] = inputString.components(separatedBy: " ").map{Int(String($0))!}
var exp = split
split.sort { $0 < $1 }
var i = 1
var count = 0
for i in 1...n {
    if (split[i-1] != exp[i-1]) {
        count += 1
    }
    
    if (count == 3) {
        break
    }
}

if (count == 3) {
    print("NO")
} else {
   print("YES") 
}
//  [swift]
import Foundation
import CoreFoundation

#if swift(>=4.0)
#else
extension String {
    func split(separator separator: Character) -> [String] {
        return self.characters.split(separator).map{String($0)}
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
extension Array where Element: Comparable {
    func max() -> Element? {
        return self.maxElement()
    }
    func min() -> Element? {
        return self.minElement()
    }
    func sorted() -> Array {
        return self.sort()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    func joined(separator separator: String = " ") -> String {
        return self.map{String($0)}.joinWithSeparator(separator)
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func reverse() {
        self = self.reversed()
    }
    func enumerated() -> EnumerateSequence<[Element]> {
        return self.enumerate()
    }
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: Character = " ") -> [String] {
    return readLine()!.split(separator: separator)
}
func readIntSplit(by separator: Character = " ") -> [Int] {
    return readLine()!.split(separator: separator).map{Int($0)!}
}
infix operator ** { associativity right precedence 155 }    // 右結合，乗除算より強くビットシフトより弱い
func **(lhs: Int, rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
func **(lhs: Int, rhs: Double) -> Double {
    return pow(Double(lhs), rhs)
}
//func gcd(_ x: Int, _ y: Int) -> Int {
//    return y>0 ? gcd(y, x%y) : x
//}
//func lcm(_ x: Int, _ y: Int) -> Int {
//    return x * y / gcd(x, y)
//}

/*************** テストスペース ***************/

//arr.sort{$0.0==$1.0 ? $0.1<$1.1 : $0.0<$1.0}  // タプル配列のソート
//print("Ready")

/*************** メインプログラム ***************/

let N = readInt()!
let p = readIntSplit()
let q = p.sorted()
var ans = "NO"
for i in 0..<N {
    for j in i+1..<N {
        var tmp = p
        swap(&tmp[i], &tmp[j])
        if tmp == q {
            ans = "YES"
        }
    }
}
if p == q {
    ans = "YES"
}
print(ans)
//  [typescript]
// general helpers
const debug = (message?: any, ...optionalParams: any[]) => {
  if (process.env.LOCAL_DEBUG === '1') console.log(message, ...optionalParams)
}

// helpers
const parseLines = (
  lines: string[]
): { N: number[] } => {
  const N = lines[1].split(' ').map(line => +line)
  const obj = { N }
  debug(obj)
  return obj
}
// solver
export const solve = (lines: string[]): string => {
  const { N } = parseLines(lines)
  const origin = []
  for (let i = 1; i <= N.length; i++) {
    origin.push(i)
  }

  let diffCount = 0
  for (let i = 0; i < origin.length; i++) {
    if (origin[i] !== N[i]) {
      diffCount++
    }
  }

  if (diffCount === 2 || diffCount === 0) {
    return 'YES'
  } else {
    return 'NO'
  }
}

// main
const main = (lines: string[]) => {
  console.log(solve(lines))
}

// exec main function for submit
if (process.env.LOCAL_DEBUG !== '1') {
  const { stdin: input, stdout: output } = process
  input.resume()
  input.setEncoding('utf8')
  const lines: string[] = []
  require('readline')
    .createInterface({ input, output })
    .on('line', (line: string) => lines.push(line))
    .on('close', () => main(lines))
}
//  [typescript]
import * as fs from "fs";

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
//const n = +input[0];
//const a = [];
//for(let i=0;i<n;i++){
//	a.push(input[i+1].split(" ").map((x:string):number=>+x));
//}

//const [n, m] = input[0].split(" ").map((x: string): number => +x);
//const a = input[1].split(" ").map((x: string): number => +x);

function compareFunc(a, b){
    return a-b;
}

const n: number = +input[0];
const p: number[] = input[1].split(' ').map((x: string): number => +x);

let temp:number = 0;

for(let i = 0; i < n; i++){
    if(p[i] !== i+1){
        temp++;
    }
}

if(temp <= 2){
    console.log('YES');
}else{
    console.log('NO');
}
//  [typescript]
import * as fs from 'fs';

namespace AtCoder.abc135 {

    export class Program {
        args: string[];

        constructor(args: string[]) {
            this.args = args;
        }

        /**
         * in
         * 5
         * 5 2 3 4 1
         * out
         * Yes
         */
        main(): void {
            let p: number [] = this.args[1].split(' ').map(x => parseInt(x, 10));
            const sorted: number[] = this.args[1].split(' ').map(x => parseInt(x, 10))
                .sort((a: number, b: number) => a - b);
            let cnt: number = 0;
            for (let i = 0; i < p.length; i++) {
                if (p[i] !== sorted[i]) {
                    cnt++;
                }

                if (cnt > 2) {
                    console.log('NO');
                    return;
                }
            }
            console.log('YES');
        }
    }

}

const args = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n');
const prg = new AtCoder.abc135.Program(args);
prg.main();
//  [python]
h, n = list(map(int, input().split()))
ab = []
for i in range(n):
    a, b = list(map(int, input().split()))
    ab.append((a, b))
ab.sort(key=lambda ab: (ab[0]/ab[1], -ab[0]), reverse=True)

import sys
sys.setrecursionlimit(100000000)

mem = [-1 for i in range(h)]
def solve(h):
    best = float('inf')
    for a,b in ab:
        if h - a <= 0:
            val = b
        else:
            if mem[h - a] != -1:
                val = b + mem[h - a]
            else:
                mem[h - a] = solve(h - a)
                val = b + mem[h-a]
        if val < best:
            best = val
        else:
            break
    return best

print(solve(h))
//  [python]
import sys
sys.setrecursionlimit(100000000)

INF = 10**10
def solve(h, n, a, b):
    ab = sorted(zip(a, b), key=lambda _:(_[0]/_[1], -_[0]), reverse=True)
    dp = [-1] * h
    def f(h):
        best = INF
        for x, y in ab:
            if h-x <= 0:
                score = y
            else:
                if dp[h-x] == -1:
                    dp[h-x] = f(h-x)
                score = y + dp[h-x]
            if score < best:
                best = score
            else:
                break
        return best
    return f(h)

h, n = map(int, input().split())
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())
print(solve(h, n, a, b))
//  [python]
#import sys
#sys.setrecursionlimit(10**9)

H, N = map(int, input().split())
magic = [_ for _ in range(N)]

for k in range(N):
  magic[k] = list(map(int, input().split()))
  magic[k].append(magic[k][0]/magic[k][1])

magic.sort(key = lambda x: x[2], reverse=True)
ans = [0 for _ in range(H+1)]
visited = [0]
anskouho = [float('inf')]
ans2 = float('inf')
"""
def solve(start, power, point, maryoku):
  if start == H:
    print(min(point, min(anskouho)))
    exit()
  elif start > H:
    anskouho.append(point)
    return 0
  elif ans[start] != 0:
    return 0
  else:
    visited.append(start)
    ans[start] = point
    solve(start+power, power, point+maryoku, maryoku)
"""
for k in range(N):
  for item in visited:
    #solve(item+magic[k][0], magic[k][0], ans[item] + magic[k][1], magic[k][1])
    start = item+magic[k][0]
    power = magic[k][0]
    point = ans[item]+ magic[k][1]
    maryoku = magic[k][1]
    for _ in range(10**5):
      if start == H:
        print(min(point, ans2))
        exit()
      elif start > H:
        ans2 = min(ans2, point)
        break
      elif ans[start]!=0:
        break
      else:
        visited.append(start)
        ans[start] = point
        start += power
        point += maryoku
      
print(ans2)
//  [python]
import math

def main():
    H,N=map(int,input().split())

    inf=float('inf')
    dp=[0]+[inf]*H

    for i in range(N):
        A,B=map(int,input().split())
        if A>=H:
            #dp[-1]=min(B,dp[-1])
            if B < dp[-1]:
                dp[-1]=B
        else:
            for j in range(A,H+1):
                #dp[j]=min(dp[j-A]+B,dp[j])
                if dp[j-A]+B<dp[j]:
                    dp[j]=dp[j-A]+B

                if j > H-A:
                    #dp[-1]=min(dp[-1],dp[j]+B)
                    if dp[j]+B < dp[-1]:
                        dp[-1]=dp[j]+B

    print(dp[-1])

main()