시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB345463416.585%

문제

버블 정렬은 다음과 같은 의사 코드를 가지는 가장 간단한 정렬 방법 중 하나이다.

void bubble_sort(int *a, int n) {
    int i, j;
    for (i = 0; i < n - 1; ++i) {
        for (j = 0; j < n - 1; ++j) {
            if (a[j] > a[j + 1]) {
                /* 순서가 틀린 쌍이라면, 두 쌍을 교환한다. */ 
                /* 이때 두 쌍의 교환 횟수는 1 증가한다. */
                int x = a[j];
                a[j] = a[j + 1];
                a[j + 1] = x;
            }
        }
    }
}

길이 n인 배열 A에 대해서 A*를 정의하고자 한다. A*는 배열 A의 i번째 원소와 j번째 원소를 한번만 바꿔놓은 배열이다. (1 ≤ i < j ≤ n).

모든 배열 A* 중, 교환 횟수가 최소인 배열 A*의 교환 횟수를 출력하라.

입력

첫 번째 줄에 정수 N이 주어지며, 이후 N개의 줄에 배열 A가 A1, ..., AN 순서로 주어진다.

출력

배열 A* 중 교환 횟수가 최소인 배열의 교환 횟수를 출력한다.

제한

  • 1 ≤ N ≤ 100,000
  • 1 ≤ Ai ≤ 1,000,000,000

예제 입력 1

5
10
3
6
8
1

예제 출력 1

0

1과 10을 바꾸면 {1,3,6,8,10} 으로 정렬된 형태가 완성되기에 최솟값은 0이다.

예제 입력 2

5
3
1
7
9
5

예제 출력 2

2

예제 입력 3

3
1
2
3

예제 출력 3

1
W3sicHJvYmxlbV9pZCI6IjU1MzEiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWJjODRcdWJlMTQgXHVjODE1XHViODJjIiwiZGVzY3JpcHRpb24iOiI8cD5cdWJjODRcdWJlMTQgXHVjODE1XHViODJjXHVjNzQwIFx1YjJlNFx1Yzc0Y1x1YWNmYyBcdWFjMTlcdWM3NDAgXHVjNzU4XHVjMGFjIFx1Y2Y1NFx1YjRkY1x1Yjk3YyBcdWFjMDBcdWM5YzBcdWIyOTQgXHVhYzAwXHVjN2E1IFx1YWMwNFx1YjJlOFx1Z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