#include <iostream>
#include <cstring>
#include <algorithm>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int merge(int a[],int s,int e){
int mid = (s+e)/2;
int i = s,j = (mid+1),k = s;
int coun = 0;
int temp[1000] = {0};
while(i<=mid & j<=e){
if(a[i]<=a[j]){
temp[k++] = a[i++];
}
else{
coun+=(mid-i+1);
temp[k++] = a[j++];
}
}
while(i<=mid){
temp[k++] = a[i++];
}
while(j<=e){
temp[k++] = a[j++];
}
for(int i = s;i<k;i++){
a[i] = temp[k];
}
return coun;
}
int merge_sort(int a[],int s,int e){
if(s>=e){
return 0;
}
else{
int mid = (s+e)/2;
int x = merge_sort(a,s,mid);
int y = merge_sort(a,mid+1,e);
int z = merge(a,s,e);
return (x+y+z);
}
}
int main(){
int arr[] = {1,5,2,3,6,0};
int t = -1;
t = merge_sort(arr,0,5);
cout<<t;
}