/*

                Name: Kartik Gupta
                IIT-Guwahati

*/

#include <bits/stdc++.h>
#define ll long long
#define maxn 100001
#define vint vector<int>
#define FOR(i,n) for(int i = 0 ; i < n ; i++)

using namespace std;

double findProb(int num_swaps)
{
    /* Number of Moves to do num_swaps */
    /* Always starting with Jeff */
    if(num_swaps == 0)
    {
        return 0 ;
    }
    if(num_swaps == 1)
    {
        return 1.0 ;
    }
    else if(num_swaps == 2)
    {
        return 4.0 ;
    }

    return 4.0 + findProb(num_swaps-2) ;

}

int main( int argc , char ** argv )
{
    ios_base::sync_with_stdio(false) ;
    cin.tie(NULL) ;

    int n ; /* Number of Elements in Sequence */
    cin >> n ;
    vint p(n) ;

    FOR(i,n)
    {
        cin >> p[i] ;
    }

    /*
        Jeff during his move swaps any two elements not in correct order
        Furik for HEADS swaps any two elements that aren't in correct order!
        Furik for TAILS swaps any two elements that are in correct order!
        IF ITS TAILS AND THERE ARE NO ELEMENTS THAT ARE IN CORRECT ORDER! HE FLIPS AGAIN!
        IF ITS HEADS AND ALL ELEMENTS ARE IN ORDER! COOOOOOOL!
    */

    /*  Bit like bubble sort! */
    /*
        Maybe find the number of *correct* swaps required to take the sequence to final order
    */

    /*
        Given a sequence! = FIND THE NUMBER OF CORRECT SWAPS!
        RUN BUBBLE SORT ON IT?
    */

    ll numSwaps = 0 ;
    vint cpy(p) ;
    for(int i = 0 ; i < n ; i++)
    {
        bool sorted = true ;

        for(int j = 0 ; j < n-i-1 ; j++)
        {
            /* Consider Elements till n-i! Onwards they are sorted */
            if(cpy[j] > cpy[j+1])
            {
                swap(cpy[j],cpy[j+1]) ;
                sorted = false ;
                numSwaps++ ;
            }
        }

        if(sorted)
        {
            break ;
        }
    }

    /* Now I have number of swaps to do! */

    cout << setprecision(6) << fixed ;
    cout << findProb(numSwaps) << '\n' ;

    return 0 ;
}


#include<iostream>
#include<vector>
#include<set>
#include<climits>
#include<cstring>
#include<map>
#include<queue>
using namespace std;

long long F[10000000];
int vet[4000];
int N;
int main(void)
{
	cin >> N;
	int NMR=0;
	for(int i=0;i<N;i++)
		cin >> vet[i];
	for(int i=1;i<N;i++)
		for(int k=0;k<i;k++)
			if(vet[k]>vet[i])
				NMR++;
	for(int i=1;i<=NMR;i++)
	{
		if(i==1)
			F[i]=1;
		else F[i]=4+F[i-2];
		//cout << i << " " << F[i] << endl;
	}
	if(NMR==0)
	{
		cout << 0;return 0;
	}
	else if(NMR==1)
	{
		cout << 1;return 0;
	}
	else cout << F[NMR];
	//for(int i=0;i<=NMR;i++)
		//cout << i << " " << F[i] << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector < int > VI;
typedef pair < int,int > II;
typedef vector < II > VII;
#define MOD 1000000007
#define EPS 1e-12
#define N 200100
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define ALL(v) v.begin(),v.end()
#define SZ(a) (int)a.size()
#define FILL(a,b) memset(a,b,sizeof(a))
#define SI(n) scanf("%d",&n)
#define SLL(n) scanf("%lld",&n)
#define PLLN(n) printf("%lld\n",n)
#define PIN(n) printf("%d\n",n)
#define REP(i,j,n) for(LL i=j;i<n;i++)
#define TR1(x) cerr<<#x<<" : "<<x<<endl;
#define TR2(x,y) cerr<<#x<<" : "<<x<<" | "<<#y<<" : "<<y<<endl;
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
int a[3005];
int ans[10000007];
int main(){
    int n , inv = 0; SI(n);
    REP(i,0,n) SI(a[i]);
    REP(i,0,n) REP(j,i+1,n) if(a[i] > a[j]) inv ++;
    ans[0] = 0;
    REP(i,1,inv+1)
        if(i & 1)
            ans[i] = ans[i-1] + 1;
        else
            ans[i] = ans[i-1] + 3;
    printf("%.9lf\n",(double)ans[inv]);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector < int > VI;
typedef pair < int,int > II;
typedef vector < II > VII;
#define MOD 1000000007
#define EPS 1e-12
#define N 200100
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define ALL(v) v.begin(),v.end()
#define SZ(a) (int)a.size()
#define FILL(a,b) memset(a,b,sizeof(a))
#define SI(n) scanf("%d",&n)
#define SLL(n) scanf("%lld",&n)
#define PLLN(n) printf("%lld\n",n)
#define PIN(n) printf("%d\n",n)
#define REP(i,j,n) for(LL i=j;i<n;i++)
#define TR1(x) cerr<<#x<<" : "<<x<<endl;
#define TR2(x,y) cerr<<#x<<" : "<<x<<" | "<<#y<<" : "<<y<<endl;
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
int main(){
    int n , inv = 0; SI(n);
    int a[3005];
    int ans = 0;
    REP(i,0,n) SI(a[i]);
    REP(i,0,n) REP(j,i+1,n) if(a[i] > a[j]) inv ++;
    REP(i,1,inv+1)
        if(i & 1)
            ans = ans + 1;
        else
            ans = ans + 3;
    printf("%.9lf\n",(double)ans);
    return 0;
}


#include <iostream>
using namespace std;

int v[3100];
int dp[10 * 1000 * 1000];

int main()
{
	int n;
	cin >> n;
	int inv(0);

	for (int i(1); i <= n; i++) {
		cin >> v[i];
		for (int j(i - 1); j >= 1; j--)
			if (v[i] < v[j])
				inv++;
	}

	dp[0] = 0, dp[1] = 1;
	for (int i(2); i <= inv; i++)
		dp[i] = 4 + dp[i - 2];

	cout << dp[inv];
	return 0;
}


/*
oh fuck! GG!
 	by Furude_Rika
*/
// ♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂
#include <iostream>
// ♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂
#include <stdlib.h>
// ♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂
#include <cstring>
// ♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂
#include <cstdio>
// ♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂
#include <algorithm>
// ♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂
#include <map>
// ♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂
#include <vector>
// ♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂
#include <stack>
// ♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂
#include <set>
// ♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂
#include <queue>
// ♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂
#include <fstream>
// ♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂
#include <cstdlib>
// ♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂
#include <utility>
// ♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂
#include <cmath>
// ♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂
#include <functional>
// ♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂
using namespace std;
#define ll long long
#define ull unsigned long long
#define all(x) (x).begin(), (x).end()
#define ayacin ios::sync_with_stdio(false);
#define yukari 9999999999999999
#define mod 1000000007
#define M_PI12 3.141592653
#define Parsee long double
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
#define reimu iterator
#define x first
#define y second
#define mokou __builtin_popcount
ll bit[200005],m,a[200005],num[200005];
ll sum(ll i){
	ll s=0;
	while(i>0){
		s+=bit[i];
		i-=i&-i;
	}
	return s;
}
void add(ll i,ll x){
	while(i<=m){
		bit[i]+=x;
		i+=i&-i;
	}
}
int main(){
	ll n,i,j,k;
	ayacin;
	cin>>m;
	for(i=1;i<=m;i++) cin>>a[i];
	ll ans=0;
	for(i=1;i<=m;i++){
		ans+=(i-1-sum(a[i]));
		add(a[i],1);
	}
	if(ans&1) ans=ans*2-1;
	else ans=ans*2;
	cout<<ans<<endl;
}


/*
oh fuck! GG!
 	by Furude_Rika
*/
// ♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂
#include <iostream>
// ♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂
#include <stdlib.h>
// ♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂
#include <cstring>
// ♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂
#include <cstdio>
// ♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂
#include <algorithm>
// ♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂
#include <map>
// ♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂
#include <vector>
// ♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂
#include <stack>
// ♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂
#include <set>
// ♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂
#include <queue>
// ♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂
#include <fstream>
// ♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂
#include <cstdlib>
// ♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂
#include <utility>
// ♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂
#include <cmath>
// ♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂
#include <functional>
// ♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂♂
using namespace std;
#define ll long long
#define ull unsigned long long
#define all(x) (x).begin(), (x).end()
#define ayacin ios::sync_with_stdio(false);
#define yukari 9999999999999999
#define mod 1000000007
#define M_PI12 3.141592653
#define Parsee long double
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
#define reimu iterator
#define x first
#define y second
#define mokou __builtin_popcount
ll bit[200005],m,a[200005],num[200005];
ll sum(ll i){
	ll s=0;
	while(i>0){
		s+=bit[i];
		i-=i&-i;
	}
	return s;
}
void add(ll i,ll x){
	while(i<=m){
		bit[i]+=x;
		i+=i&-i;
	}
}
int main(){
	ll n,i,j,k;
	ayacin;
	cin>>m;
	for(i=1;i<=m;i++) cin>>a[i];
	ll ans=0;
	for(i=1;i<=m;i++){
		ans+=(i-1-sum(a[i]));
		add(a[i],1);
	}
	cout<<max(0LL,ans*2-1)<<endl;
}


#include<bits/stdc++.h>
using namespace std;
int p[3005];
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n,i,j,z=0;
    cin>>n;
    for(i=0;i<n;i++)
        cin>>p[i];
    for(i=0;i<n;i++)
        for(j=i+1;j<n;j++)
            if(p[i]>p[j])
                z++;
    cout<<z*2-z%2;
}


#include <bits/stdc++.h>
#include <ext/hash_map>
using namespace std;
using namespace __gnu_cxx;

#define EPS      1e-15
#define F        first
#define S        second
#define pi       acos(-1)
#define ll       long long
#define oo       0x3f3f3f3f
#define sz(x)    (int)x.size()
#define sc(x)    scanf("%d",&x)
#define all(x)   x.begin(),x.end()
#define rall(x)  x.rbegin(),x.rend()

int n;
int a[3030];
int ans[30030000];

int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
#endif
  scanf("%d",&n);
  for(int i=1;i<=n;i++)
    scanf("%d",&a[i]);
  int inv=0;
  for(int i=1;i<=n;i++)
    for(int j=i+1;j<=n;j++)
      inv+=(a[i]>a[j]);
  ans[1]=1;
  for(int i=2;i<=inv;i++)
    ans[i]=ans[i-2]+4;
  cout<<ans[inv];
}


#include <bits/stdc++.h>
#include <ext/hash_map>
using namespace std;
using namespace __gnu_cxx;

#define EPS      1e-15
#define F        first
#define S        second
#define pi       acos(-1)
#define ll       long long
#define oo       0x3f3f3f3f
#define sz(x)    (int)x.size()
#define sc(x)    scanf("%d",&x)
#define all(x)   x.begin(),x.end()
#define rall(x)  x.rbegin(),x.rend()

int n;
int a[3030];
int ans[3030000];

int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
#endif
  scanf("%d",&n);
  for(int i=1;i<=n;i++)
    scanf("%d",&a[i]);
  int inv=0;
  for(int i=1;i<=n;i++)
    for(int j=i+1;j<=n;j++)
      inv+=(a[i]>a[j]);
  ans[1]=1;
  for(int i=2;i<=inv;i++)
    ans[i]=ans[i-2]+4;
  cout<<ans[inv];
}


#include <iostream>
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <vector>
#include <set>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <stack>
#include <string>

using namespace std;

#define mp make_pair
#define pb push_back

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const double PI = 3.14159265359;
const double EPS = 1e-6;
const int INF = (2e9);
// const ll INF = ((ll)1 << 62);

const ll P = 1e9 + 7;

vector<int> nums;
ll n;

// dp(1) = (0.5) + 0.5*(1 + dp(2));
// dp(2) = dp(1) - 0.5*(1.0)/0.5 - 1.0;
// dp(2) = dp(1) - 2.0;

// dp(1) = (0.5) + 0.5*(1.0 + dp(1) - 2.0);
// dp(1) = 0.5 + 0.5 + 0.5*dp(1) - 1.0;
// dp(1)-0.5*dp(1) = 0;

// dp(2) = 1.0 + dp(1)
// dp(1) = 0.5 + 0.5*(1 + 1.0 + dp(1))
// dp(1) = 1.5 + 0.5*dp(1)
// dp(1) = 1.5/0.5

double memo[3000*3000][2];
bool visited[3000*3000][2];

double dp(ll i, int turn){
  // double tot = (n*(n-1))/2
  if(i == 0) return 0;
  if(i == 1){
    if(!turn) return 1.0;
    else return 1.5/0.5;
  }
  if(visited[i][turn]) return memo[i][turn];
  ll res;

  if(turn == 0){
    res = (1.0 + dp(i-1, !turn));
  }
  else{
    res = (dp(i-1, !turn) - 0.5*(1 + dp(i-2, !turn)))/0.5 - 1.0;
  }

  visited[i][turn] = 1;
  return memo[i][turn] = res;
}

int main(){
  std::ios::sync_with_stdio(false);

  cin >> n;
  nums.resize(n);

  int invs = 0;
  for(int i = 0; i < n; i++) cin >> nums[i];

  for(int i = 0; i < n; i++){
    for(int j = i+1; j < n; j++){
      if(nums[j] < nums[i]) invs++;
    }
  }

  // cout << invs << endl;

  double res = dp(invs, 0);
  if(res < 0) res *= -1.0;
  cout << setprecision(12) << fixed << res << endl;

  return 0;
}


#include <iostream>
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <vector>
#include <set>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <stack>
#include <string>

using namespace std;

#define mp make_pair
#define pb push_back

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const double PI = 3.14159265359;
const double EPS = 1e-6;
const int INF = (2e9);
// const ll INF = ((ll)1 << 62);

const ll P = 1e9 + 7;

vector<int> nums;
ll n;

// dp(1) = (0.5) + 0.5*(1 + dp(2));
// dp(2) = dp(1) - 0.5*(1.0)/0.5 - 1.0;
// dp(2) = dp(1) - 2.0;

// dp(1) = (0.5) + 0.5*(1.0 + dp(1) - 2.0);
// dp(1) = 0.5 + 0.5 + 0.5*dp(1) - 1.0;
// dp(1)-0.5*dp(1) = 0;

// dp(2) = 1.0 + dp(1)
// dp(1) = 0.5 + 0.5*(1 + 1.0 + dp(1))
// dp(1) = 1.5 + 0.5*dp(1)
// dp(1) = 1.5/0.5

double memo[3000*3000][2];
bool visited[3000*3000][2];

double dp(ll i, int turn){
  if(i == 0) return 0;
  if(i == 1){
    if(!turn) return 1.0;
    else return 1.5/0.5;
  }
  if(visited[i][turn]) return memo[i][turn];
  double res;

  if(turn == 0){
    res = (1.0 + dp(i-1, !turn));
  }
  else{
    res = (1.0 + 0.5*(1.0 + dp(i-1, 0)))/0.5;
  }

  visited[i][turn] = 1;
  return memo[i][turn] = res;
}

int main(){
  std::ios::sync_with_stdio(false);

  cin >> n;
  nums.resize(n);

  int invs = 0;
  for(int i = 0; i < n; i++) cin >> nums[i];

  for(int i = 0; i < n; i++){
    for(int j = i+1; j < n; j++){
      if(nums[j] < nums[i]) invs++;
    }
  }

  // cout << invs << endl;
  if(invs == 0){
    cout << setprecision(12) << fixed << 0.0 << endl;
  }
  else{
    double res = dp(invs, 0);
    cout << setprecision(12) << fixed << res << endl;

  }

  return 0;
}


#include <iostream>
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <vector>
#include <set>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <stack>
#include <string>

using namespace std;

#define mp make_pair
#define pb push_back

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const double PI = 3.14159265359;
const double EPS = 1e-6;
const int INF = (2e9);
// const ll INF = ((ll)1 << 62);

const ll P = 1e9 + 7;

vector<int> nums;
ll n;

// dp(1) = (0.5) + 0.5*(1 + dp(2));
// dp(2) = dp(1) - 0.5*(1.0)/0.5 - 1.0;
// dp(2) = dp(1) - 2.0;

// dp(1) = (0.5) + 0.5*(1.0 + dp(1) - 2.0);
// dp(1) = 0.5 + 0.5 + 0.5*dp(1) - 1.0;
// dp(1)-0.5*dp(1) = 0;

// dp(2) = 1.0 + dp(1)
// dp(1) = 0.5 + 0.5*(1 + 1.0 + dp(1))
// dp(1) = 1.5 + 0.5*dp(1)
// dp(1) = 1.5/0.5

double memo[3000*3000][2];
bool visited[3000*3000][2];

double dp(ll i, int turn){
  if(i == 0) return 0;
  if(i == 1){
    if(!turn) return 1.0;
    else return 1.5/0.5;
  }
  if(visited[i][turn]) return memo[i][turn];
  double res;

  if(turn == 0){
    res = (1.0 + dp(i-1, !turn));
  }
  else{
    res = (1.0 + 0.5*(1.0 + dp(i-1, 0)))/0.5;
  }

  visited[i][turn] = 1;
  return memo[i][turn] = res;
}

int main(){
  std::ios::sync_with_stdio(false);

  cin >> n;
  nums.resize(n);

  int invs = 0;
  for(int i = 0; i < n; i++) cin >> nums[i];

  for(int i = 0; i < n; i++){
    for(int j = i+1; j < n; j++){
      if(nums[j] < nums[i]) invs++;
    }
  }

  memo[0][0] = 0;
  memo[0][1] = 0;
  memo[1][0] = 1.0;
  memo[1][1] = 1.5/0.5;

  for(int i = 2; i <= invs; i++){
    for(int j = 0; j < 2; j++){
      if(j == 0){
        memo[i][j] = (1.0 + memo[i-1][1]);
      }
      else{
        memo[i][j] = (1.0 + 0.5*(1.0 + memo[i-1][0]))/0.5;
      }
    }
  }

  // cout << invs << endl;
  if(invs == 0){
    cout << setprecision(12) << fixed << 0.0 << endl;
  }
  else{
    // double res = dp(invs, 0);
    cout << setprecision(12) << fixed << memo[invs][0] << endl;

  }

  return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
int a[3005];
int main(){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    int ans=0;
    for(int i=1;i<n;i++){
        for(int j=0;j<i;j++){
            if(a[i]<a[j]){
                ans++;
            }
        }
    }
    if(ans&1)
        ans=(ans<<1)-1;
    else
        ans<<=1;
    printf("%.6f\n",(double)ans);
    return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <string.h>
using namespace std;

namespace io {
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	// getchar
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	// print the remaining part
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout);
		oS = obuf;
	}
	// putchar
	inline void putc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	// input a signed integer
	template <class I>
	inline void read (I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;
	}
	// print a signed integer
	template <class I>
	inline void print (I &x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}
	//no need to call flush at the end manually!
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io :: read;
using io :: putc;
using io :: print;

int main() {
    int n, cnt = 0;
    double a[3010];
    cin>>n;
    for(int i = 0; i < n; i++)
        cin>>a[i];
    for(int i = 0; i < n; i++) {
        for(int j = i + 1; j < n; j++) {
            if(a[i] > a[j])
                cnt++;
        }
    }
    if(cnt % 2 == 0)
        printf("%f\n", (cnt * 2));
    else
        printf("%f\n", (cnt / 2 * 4 + 1));
    return 0;

}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <string.h>
using namespace std;

namespace io {
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	// getchar
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	// print the remaining part
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout);
		oS = obuf;
	}
	// putchar
	inline void putc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	// input a signed integer
	template <class I>
	inline void read (I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;
	}
	// print a signed integer
	template <class I>
	inline void print (I &x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}
	//no need to call flush at the end manually!
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io :: read;
using io :: putc;
using io :: print;

int main() {
    int n, cnt = 0;
    double a[3010];
    read(n);
    for(int i = 0; i < n; i++)
        read(a[i]);
    for(int i = 0; i < n; i++) {
        for(int j = i + 1; j < n; j++) {
            if(a[i] > a[j])
                cnt++;
        }
    }
    if(cnt % 2 == 0)
        printf("%f\n", (cnt * 2));
    else
        printf("%f\n", (cnt / 2 * 4 + 1));
    return 0;

}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <string.h>
using namespace std;

namespace io {
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	// getchar
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	// print the remaining part
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout);
		oS = obuf;
	}
	// putchar
	inline void putc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	// input a signed integer
	template <class I>
	inline void read (I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;
	}
	// print a signed integer
	template <class I>
	inline void print (I &x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}
	//no need to call flush at the end manually!
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io :: read;
using io :: putc;
using io :: print;

int n,a[3005];
int main(){
    int i,j,k;
    //freopen("352D.in","r",stdin);
	//freopen("352D.out","w",stdout);
    read(n);
    for(i=1;i<=n;i++)
		read(a[i]);
	long long int ans=0;
	for(i=2;i<=n;i++)
	{
		for(j=1;j<=i;j++)
			if(a[i]<a[j])ans++;
	}
	if(ans&1)ans=(ans<<1)-1;
	else ans=ans<<1;
    cout<<(double)ans<<endl;
    return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <string.h>
using namespace std;

namespace io {
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	// getchar
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	// print the remaining part
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout);
		oS = obuf;
	}
	// putchar
	inline void putc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	// input a signed integer
	template <class I>
	inline void read (I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;
	}
	// print a signed integer
	template <class I>
	inline void print (I &x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}
	//no need to call flush at the end manually!
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io :: read;
using io :: putc;
using io :: print;

int n,a[3005];
int main(){
    int i,j,k;
    freopen("352D.in","r",stdin);
    freopen("352D.out","w",stdout);
    read(n);
    for(i=1;i<=n;i++)
		read(a[i]);
	int ans=0;
	for(i=2;i<=n;i++)
	{
		for(j=1;j<=i;j++)
			if(a[i]<a[j])ans++;
	}
	ans=ans*2-(ans%2);
    cout<<1.0*ans<<endl;
    return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <string.h>
using namespace std;

namespace io {
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	// getchar
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	// print the remaining part
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout);
		oS = obuf;
	}
	// putchar
	inline void putc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	// input a signed integer
	template <class I>
	inline void read (I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;
	}
	// print a signed integer
	template <class I>
	inline void print (I &x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}
	//no need to call flush at the end manually!
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io :: read;
using io :: putc;
using io :: print;

int n,a[3005];
int main(){
    int i,j,k;
    read(n);
    for(i=1;i<=n;i++)
		read(a[i]);
	int ans=0;
	for(i=2;i<=n;i++)
	{
		for(j=1;j<=i;j++)
			if(a[i]<a[j])ans++;
	}
	ans=ans*2-(ans%2);
    cout<<1.0*ans<<endl;
    return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <string.h>
using namespace std;

namespace io {
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	// getchar
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	// print the remaining part
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout);
		oS = obuf;
	}
	// putchar
	inline void putc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	// input a signed integer
	template <class I>
	inline void read (I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;
	}
	// print a signed integer
	template <class I>
	inline void print (I &x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}
	//no need to call flush at the end manually!
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io :: read;
using io :: putc;
using io :: print;

int n,a[3005];
int main(){
    int i,j,k;
    //freopen("352D.in","r",stdin);
    //freopen("352D.out","w",stdout);
    read(n);
    for(i=1;i<=n;i++)
		read(a[i]);
	long long int ans=0;
	for(i=2;i<=n;i++)
	{
		for(j=1;j<=i;j++)
			if(a[i]<a[j])ans++;
	}
	ans=ans*2-(ans%2);
    cout<<(double)ans<<endl;
    return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <string.h>
using namespace std;

namespace io {
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	// getchar
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	// print the remaining part
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout);
		oS = obuf;
	}
	// putchar
	inline void putc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	// input a signed integer
	template <class I>
	inline void read (I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;
	}
	// print a signed integer
	template <class I>
	inline void print (I &x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}
	//no need to call flush at the end manually!
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io :: read;
using io :: putc;
using io :: print;

int main() {
    int n, cnt = 0;
    double a[3010];
    cin >> n;
    for(int i = 0; i < n; i++)
        read(a[i]);
    for(int i = 0; i < n; i++) {
        for(int j = i + 1; j < n; j++) {
            if(a[i] > a[j])
                cnt++;
        }
    }
    if(cnt % 2 == 0)
        printf("%f\n", (cnt * 2));
    else
        printf("%f\n", (cnt / 2 * 4 + 1));
    return 0;

}


#include<cstdio>
#include<algorithm>
#include<string.h>
#include<math.h>
using namespace std;
const int maxn = 3000 + 5;
int a[maxn];
double d[maxn*maxn];
int main(){
    int n,cnt;
  //  freopen("in.txt","r",stdin);
    while(~scanf("%d",&n)){
        cnt=0;
        for(int i=0;i<n;i++) scanf("%d",a+i);
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                if(a[i]>a[j]) cnt++;
            }
        }
        d[0]=0;
        d[1]=1;
      //  printf("%d\n",cnt);
        for(int i=2;i<=cnt;i++) d[i]=4+d[i-2];
        printf("%.6f\n",d[cnt]);
    }
    return 0;

}


#include<cstdio>
#include<algorithm>
#include<string.h>
#include<math.h>
using namespace std;
const int maxn = 3000 + 5;
int a[maxn];
double d[maxn*maxn];
int main(){
    int n,cnt;
  //  freopen("in.txt","r",stdin);
    while(~scanf("%d",&n)){
        cnt=0;
        for(int i=0;i<n;i++) scanf("%d",a+i);
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                if(a[i]>a[j]) cnt++;
            }
        }
        d[0]=0;
        d[1]=1;
//        printf("%d\n",cnt);
        for(int i=3;i<=cnt;i++) d[i]=4+d[i-2];
        printf("%.6f\n",d[cnt]);
    }
    return 0;

}


#include<bits/stdc++.h>
#define M 3005
using namespace std;
int n;
int A[M],cnt=0;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)
		scanf("%d",&A[i]);
	for(int i=1;i<=n;i++)
		for(int j=n;j>=2;j--){
			if(A[j]<A[j-1]){
				swap(A[j],A[j-1]);
				cnt++;
			}
		}
	printf("%d\n",cnt*2-cnt%2);
	return 0;
}


#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int N,A[3005],M=0;
int main(){
	scanf("%d",&N);
	for(int i=1;i<=N;i++) scanf("%d",&A[i]);
	for(int i=1;i<N;i++)
	for(int j=i+1;j<=N;j++)
	 if(A[i]>A[j]) M++;
//	cout<<M<<endl;
	if(M%2==0) printf("%.7f\n",M*2.0);
	else printf("%.7f\n",M*2.0-1);
	return 0;
}


#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int N,A[3005],M=0;
int main(){
	scanf("%d",&N);
	for(int i=1;i<=N;i++) scanf("%d",&A[i]);
	for(int i=1;i<N;i++)
	for(int j=i+1;j<=N;j++)
	 if(A[i]>A[j]) M++;
	cout<<M<<endl;
	if(M%2==0) printf("%.7f\n",M*2.0);
	else printf("%.7f\n",M*2.0-1);
	return 0;
}


#include<iostream>
using namespace std;
const int maxn=3000+5;
int a[maxn];
double d[maxn*maxn];
int main(void)
{

    int n,cnt;
    while(scanf("%d",&n)!=EOF)
    {
        cnt=0;
        for(int i=0;i<n;i++)
            scanf("%d",a+i);
        for(int i=0;i<n;i++)
        {
            for(int j=i+1;j<n;j++)
                if(a[i]>a[j])
                    cnt++;
        }
        d[0]=0;
        d[1]=1;
        for(int i=2;i<=cnt;i++)
            d[i]=d[i-2]+4;
        printf("%.6f\n",d[cnt]);
    }

    return 0;
}
	 	   	  		  		      				  		 	//hellobig_tq//hello


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cassert>
#include <algorithm>
#include <iomanip>
#include <ctime>
#include <cmath>
#include <bitset>

#pragma comment(linker, "/STACK:256000000")

using namespace std;

typedef long long int int64;
typedef long double double80;

const int INF = (1 << 29) + 5;
const int64 LLINF = (1ll << 59) + 5;
const int MOD = 1000 * 1000 * 1000 + 7;

const int MAX_N = 3000 + 5;

int n;
int arr[MAX_N];
double80 dp[MAX_N*MAX_N];

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	scanf("%d", &n);

	for (int i = 0; i < n; ++i)
	{
		scanf("%d", &arr[i]);
	}

	int cnt_move = 0;
	for (int i = n - 1; i > 0; --i)
	{
		for (int j = 0; j < i; ++j)
		{
			if (arr[j] > arr[j + 1]) swap(arr[j], arr[j + 1]), ++cnt_move;
		}
	}

	if (cnt_move & 1) printf("%d.00000000000000000000\n", 1 + 4 * (cnt_move >> 1));
	else printf("%d.00000000000000000000\n", 4 * (cnt_move >> 1));

	fclose(stdin);
	fclose(stdout);

	return 0;
}


#include<iostream>
using namespace std;
const int maxn=3000+5;
int a[maxn];
double d[maxn*maxn];
int main(void)
{

    int n,cnt;
    while(scanf("%d",&n)!=EOF)
    {
        cnt=0;
        for(int i=0;i<n;i++)
            scanf("%d",a+i);
        for(int i=0;i<n;i++)
        {
            for(int j=i+1;j<n;j++)
                if(a[i]>a[j])
                    cnt++;
        }
        d[0]=0;
        d[1]=1;
        for(int i=2;i<=cnt;i++)
            d[i]=d[i-2]+4;
        printf("%.6f\n",d[cnt]);
    }

    return 0;
}
	 	   	  		  		      				  		 	//hellobig_tq//hello//hello


#include<bits/stdc++.h>
#define ll long long int
#define ite iterator
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define ioS ios::sync_with_stdio(false);
#define re0 return 0;
using namespace std ;

ll n,i,j,k,y,x,ans1,ans2,lo,hi,an2s,q,flag,ans,t,wt,z,m,place;
ll inf = 10000000000000 ;
 ll b[101001],a[5010501],vis[1001][1001] ;
double dp[100000] ;
vector<ll>v  ;
vector<ll> u ;

map<ll,ll> m1 ;
set<ll> s ;
set<ll>::iterator itr,itr1,itr2  ;

int main(){
    ioS ;
ll inv=0;
cin >>n ;
for(i=0;i<n;i++){cin >> a[i] ;}
for(i=0;i<n;i++){for(j=i+1;j<n;j++){if(a[j]<a[i]){inv++;}}}

dp[1]=1.0 ;

for(i=2;i<=inv;i++){
    dp[i] = 4.0+dp[i-2]*1.0 ;
}

printf("%0.9f",dp[inv]) ;

}


# include <bits/stdc++.h>
using namespace std;

int n;
int perm[3002];
long double dp[3002 * 3002];

int main(){
 ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 cin >> n;
 int cnt = 0;
 for(int i = 0; i < n; i++){
   cin >> perm[i];
   for(int j = 0; j < i; j++){
    if(perm[j] > perm[i]) cnt++;
   }
 }
 dp[0] = 0;
 dp[1] = 1;

 for(int i = 2; i <= cnt; i++)
  dp[i] = dp[i-2] + 4;

 cout << setprecision(9) << dp[cnt] << '\n';
 return 0;
 }


#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)

int a[3010];

int main() {
    int n;
    scanf("%d", &n);

    int i;
    REP(i, n) scanf("%d", a + i);

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n - 1; ++j) {
            if (a[j] > a[j + 1]) ++ans, swap(a[j], a[j + 1]);
        }
    }

    printf("%d.000000\n", (ans + 1) / 2 + ans / 2 * 3);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#if !ONLINE_JUDGE
#include "debug.h"
#else
#endif

typedef long long int LL;
typedef unsigned long long LLU;
typedef long double LD;

#define INF 10001000100LL
#define MOD 1000000007
#define F first
#define S second
#define PB push_back
#define MK make_pair
#define PP pop_back
#define LEN(vale) strlen(vale)
#define SZ(vale) (int)vale.size()
#define SQ(A) ((A)*(A))
#define pc putchar
#define gc getchar
#define FI(i12,fa,fb) for(i12=fa;i12<fb;++i12)
#define FD(i12,fa,fb) for(i12=fa;i12>fb;--i12)
#define FT(it,S) for(it = (S).begin(); it != (S).end(); ++it)
#define bits(vale) __builtin_popcount(vale)
#define VT vector

#define SET1(array,val,sz) for(int i13=0;i13<sz;i13++)array[i13]=val;
#define SET2(array,val,sz1,sz2) for(int i13=0;i13<sz1;i13++)for(int i14=0;i14<sz2;i14++)array[i13][i14]=val;

#define ALL(a) a.begin(),a.end()
#define LB (lower_bound)
#define UB (upper_bound)

#define SI(vale) scanf("%d",&vale)
#define PI(vale) printf("%d\n",vale)
#define PIS(vale) printf("%d ",vale)
#define SL(vale) scanf("%lld",&vale)
#define PL(vale) printf("%lld\n",vale)
#define PLS(vale) printf("%lld ",vale)
#define SS(vale) scanf("%s",vale)
#define PS(vale) printf("%s\n",vale)
#define NL printf("\n")
#define PLD(vale) cout << fixed; cout.precision(12); cout << vale <<"\n"
#define TCS() int testcase; SI(testcase);while(testcase--)

typedef pair<int,int> PR;
bool deb = false;
const int N = 4000011;
int a[N];
LL ans[N];

int main(){
       //clock_t tStart = clock();
       int i,j,n;
       //TCS(){
       SI(n);
       FI(i,1,n+1)
              SI(a[i]);

       int inv = 0;
       FI(i,1,n+1){
              FI(j,1,n+1){
                     if(i > j && a[i] < a[j])
                            inv++;
              }
       }

       bool ok = 0;
       if(inv&1)
              inv--,ok = 1;

       ans[1] = 1;
       for(i=2;i<=inv;i+=2)
              ans[i] = 4 + ans[i-2];
       if(ok)
              ans[inv]++;
       PL(ans[inv]);

       //exectime();
       return 0;
}


#include <bits/stdc++.h>
using namespace std;

#if !ONLINE_JUDGE
#include "debug.h"
#else
#endif

typedef long long int LL;
typedef unsigned long long LLU;
typedef long double LD;

#define INF 10001000100LL
#define MOD 1000000007
#define F first
#define S second
#define PB push_back
#define MK make_pair
#define PP pop_back
#define LEN(vale) strlen(vale)
#define SZ(vale) (int)vale.size()
#define SQ(A) ((A)*(A))
#define pc putchar
#define gc getchar
#define FI(i12,fa,fb) for(i12=fa;i12<fb;++i12)
#define FD(i12,fa,fb) for(i12=fa;i12>fb;--i12)
#define FT(it,S) for(it = (S).begin(); it != (S).end(); ++it)
#define bits(vale) __builtin_popcount(vale)
#define VT vector

#define SET1(array,val,sz) for(int i13=0;i13<sz;i13++)array[i13]=val;
#define SET2(array,val,sz1,sz2) for(int i13=0;i13<sz1;i13++)for(int i14=0;i14<sz2;i14++)array[i13][i14]=val;

#define ALL(a) a.begin(),a.end()
#define LB (lower_bound)
#define UB (upper_bound)

#define SI(vale) scanf("%d",&vale)
#define PI(vale) printf("%d\n",vale)
#define PIS(vale) printf("%d ",vale)
#define SL(vale) scanf("%lld",&vale)
#define PL(vale) printf("%lld\n",vale)
#define PLS(vale) printf("%lld ",vale)
#define SS(vale) scanf("%s",vale)
#define PS(vale) printf("%s\n",vale)
#define NL printf("\n")
#define PLD(vale) cout << fixed; cout.precision(12); cout << vale <<"\n"
#define TCS() int testcase; SI(testcase);while(testcase--)

typedef pair<int,int> PR;
bool deb = false;
const int N = 100011;
int a[N];
LL ans[N];

int main(){
       //clock_t tStart = clock();
       int i,j,n;
       //TCS(){
       SI(n);
       FI(i,1,n+1)
              SI(a[i]);

       int inv = 0;
       FI(i,1,n+1){
              FI(j,1,n+1){
                     if(i > j && a[i] < a[j])
                            inv++;
              }
       }

       bool ok = 0;
       if(inv&1)
              inv--,ok = 1;

       ans[1] = 1;
       for(i=2;i<=inv;i+=2)
              ans[i] = 4 + ans[i-2];
       if(ok)
              ans[inv]++;
       PL(ans[inv]);

       //exectime();
       return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 3100;
int a[maxn];
int main() {

    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; ++i) {
        cin >> a[i];
        for(int j = 1; j < i; ++j) {
            if(a[j] > a[i]) ans++;
        }
    }
    if(ans & 1) ans = (ans - 1) * 2 + 1;
    else ans = ans * 2;
    cout << ans << endl;

    return 0;
}


#include<bits/stdc++.h>
#define in freopen("input.txt","r",stdin)
#define out freopen("output.txt","w",stdout)

#define inp freopen(".in","r",stdin)
#define outp freopen(".out","w",stdout)

using namespace std;

#define pb push_back
#define pf push_front
#define p_f pop_front
#define p_b pop_back
#define LL long long int
#define LD long double
#define MP make_pair
#define sqr(x) (x*x)
#define fi first
#define dist(x,y,xx,yy) sqrt( (x-xx)*(x-xx)+(y-yy)*(y-yy) )
#define lenint int intsi(int x){ int cnt=0; while(x>0){cnt++;x/=10;} return (cnt); }
#define se second
#define all(v) v.begin(),v.end()
#define sc scanf
#define DEBUG(a) cout<<#a<<" -> "<<a<<endl;
#define pr printf
#define si size()
#define str strlen
#define time clock()/(double)CLOCKS_PER_SEC
#define gcd LL GCD(LL a,LL b){ if(b==0)return a;else return GCD(b,a%b); }
const int INF=(-1u)/2;
const long long int INF2=(-1ull)/2;
int a,b,i,d[1011000],j,k,n,m,timer=0,l,r,x,y,mp[100010];
int c[1011000],cnt=0,fl=0,a2,a3=-1000000,ans=0,t[2][2010][2010*2];
int dp[2][2010];
int N=2003*2;
vector<int>v;
void update( int idx,int id1,int id2 )
{
    while( idx<=N )
    {
        t[id1][id2][idx]++;
        idx+=(idx&-idx);
    }
}
int take( int idx,int id1,int id2 )
{
    int sm=0;
    while( idx>0 )
    {
        sm+=t[id1][id2][idx];
        idx-=(idx&-idx);
    }
    return sm;
}
main()
{
    #ifndef ONLINE_JUDGE
        in;out;
    #endif
    ios_base::sync_with_stdio(0);
    cin>>n;
    for( i=0;i<n;i++ )
    {
        cin>>c[i];
        c[i]=abs(c[i]);
    }
    for( i=0;i<n;i++ )
    {
        x=0;
        y=0;
        for( j=0;j<i;j++ )
        {
            if( abs(c[j])<c[i] )x++;
        }
        for( j=i+1;j<n;j++ )
        {
            if( c[j]<c[i] )y++;
        }
        if( x<y )c[i]*=-1;
    }
    x=0;
    for( i=0;i<n;i++ )
    {
        for( j=i+1;j<n;j++ )
        {
            if( c[i]>c[j] )x++;
        }
    }
    cout<<x<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define in freopen("input.txt","r",stdin)
#define out freopen("output.txt","w",stdout)

#define inp freopen(".in","r",stdin)
#define outp freopen(".out","w",stdout)

using namespace std;

#define pb push_back
#define pf push_front
#define p_f pop_front
#define p_b pop_back
#define LL long long int
#define LD long double
#define MP make_pair
#define sqr(x) (x*x)
#define fi first
#define dist(x,y,xx,yy) sqrt( (x-xx)*(x-xx)+(y-yy)*(y-yy) )
#define lenint int intsi(int x){ int cnt=0; while(x>0){cnt++;x/=10;} return (cnt); }
#define se second
#define all(v) v.begin(),v.end()
#define sc scanf
#define DEBUG(a) cout<<#a<<" -> "<<a<<endl;
#define pr printf
#define si size()
#define str strlen
#define time clock()/(double)CLOCKS_PER_SEC
#define gcd LL GCD(LL a,LL b){ if(b==0)return a;else return GCD(b,a%b); }
const int INF=(-1u)/2;
const long long int INF2=(-1ull)/2;
int a,b,i,d[10011000],j,k,n,m,timer=0,l,r,x,y,mp[100010];
int c[1011000],cnt=0,fl=0,a2,a3=-1000000,ans=0,t[2][2010][2010*2];
int dp[2][2010];
int N=2003*2;
vector<int>v;
void update( int idx,int id1,int id2 )
{
    while( idx<=N )
    {
        t[id1][id2][idx]++;
        idx+=(idx&-idx);
    }
}
int take( int idx,int id1,int id2 )
{
    int sm=0;
    while( idx>0 )
    {
        sm+=t[id1][id2][idx];
        idx-=(idx&-idx);
    }
    return sm;
}
main()
{
    #ifndef ONLINE_JUDGE
        in;out;
    #endif
    ios_base::sync_with_stdio(0);
    cin>>n;
    for( i=0;i<n;i++ )
    {
        cin>>c[i];
    }
    for( i=0;i<n;i++ )
    {
        for( j=i+1;j<n;j++ )
        {
            if( c[j]<c[i] )x++;
        }
    }
    d[1]=1;
    for( i=2;i<=x;i++ )d[i]=d[i-2]+4;
    cout<<d[x]<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<ll,ll>
#define X first
#define Y second
#define endl '\n'
#define gcd __gcd
#define lcm(x,y) (((x)*(y))/(gcd((x),(y))))
#define smin(x,y) ((x)=min((x),(y)))
#define smax(x,y) ((x)=max((x),(y)))
#define obt __builtin_popcount
#define pb push_back
#define pob pop_back
#define dbg(x) cerr<<#x<<": "<<x<<endl
using namespace std;
const ld INF=1LL<<60,EPS=1LL>>60;
ll in(){char c;while(c=getchar(),c<'0'||c>'9');ll x=0;while(c>='0'&&c<='9'){x=x*10+c-48;c=getchar();}return x;}
void out(ll x){ll len=0,data[20];while(x){data[len++]=x%10;x/=10;}if(!len)data[len++]=0;while(len--)putchar(data[len]+48);putchar('\n');}
ll a[10000];
int main()
{
    int n,ans=0;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<n;i++)
        for(int j=i;j>0 && a[j-1]>a[j];j--)
            swap(a[j],a[j-1]),
            ans++;
    if(ans)
        cout<<ans*2-1<<endl;
    else
        cout<<0<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[10000],n,ans;
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<n;i++)
        for(int j=i;j>0 && a[j-1]>a[j];j--)
            swap(a[j],a[j-1]),
            ans++;
    cout<<ans*2-ans%2<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define LL long long
#define reg register
#define Raed Read
#define clr(a,b) memset(a,b,sizeof a)
#define Mod(x) (x>=mod)&&(x-=mod)
#define debug(x) cerr<<#x<<" = "<<x<<endl;
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)>(b)?(b):(a))
#define rep(a,b,c) for(reg int a=(b),a##_end_=(c); a<=a##_end_; ++a)
#define ret(a,b,c) for(reg int a=(b),a##_end_=(c); a<a##_end_; ++a)
#define drep(a,b,c) for(reg int a=(b),a##_end_=(c); a>=a##_end_; --a)
#define erep(i,G,x) for(int i=(G).Head[x]; i; i=(G).Nxt[i])
//#pragma GCC target("avx,avx2,sse4.2")
//#pragma GCC optimize(3)

inline int Read(void) {
	int res=0,f=1;
	char c;
	while(c=getchar(),c<48||c>57)if(c=='-')f=0;
	do res=(res<<3)+(res<<1)+(c^48);
	while(c=getchar(),c>=48&&c<=57);
	return f?res:-res;
}

template<class T>inline bool Min(T &a, T const&b) {
	return a>b?a=b,1:0;
}
template<class T>inline bool Max(T &a, T const&b) {
	return a<b?a=b,1:0;
}

const int N=3e3+5,M=1e6+5,mod=998244353;

typedef pair<int,int> Pair;

bool MOP1;

int A[N];

bool MOP2;

inline void _main() {
//  cerr<<"M="<<(&MOP2-&MOP1)/1024.0/1024.0<<endl;
	int n=Read(),tot=0;
	rep(i,1,n)A[i]=Read();
	rep(i,1,n)rep(j,i+1,n)if(A[i]>A[j])tot++;
	printf("%.6lf",(double)(tot*2-tot%2));
}

signed main() {
	_main();
	return 0;
}


#include<iostream>
using namespace std;
const int maxn=3000+5;
int a[maxn];
double d[maxn*maxn];
int main(void)
{

    int n,cnt;
    while(scanf("%d",&n)!=EOF)
    {
        cnt=0;
        for(int i=0;i<n;i++)
            scanf("%d",a+i);
        for(int i=0;i<n;i++)
        {
            for(int j=i+1;j<n;j++)
                if(a[i]>a[j])
                    cnt++;
        }
        d[0]=0;
        d[1]=1;
        for(int i=2;i<=cnt;i++)
            d[i]=d[i-2]+4;
        printf("%.6f\n",d[cnt]);
    }

    return 0;
}


#include<iostream>
using namespace std;
const int maxn=3000+5;
int a[maxn];
double d[maxn*maxn];
int main(void)
{

    int n,cnt;
    while(scanf("%d",&n)!=EOF)
    {
        cnt=0;
        for(int i=0;i<n;i++)
            scanf("%d",a+i);
        for(int i=0;i<n;i++)
        {
            for(int j=i+1;j<n;j++)
                if(a[i]>a[j])
                    cnt++;
        }
        d[0]=0;
        d[1]=1;
        for(int i=2;i<=cnt;i++)
            d[i]=d[i-2]+4;
        printf("%.6f\n",d[cnt]);
    }

    return 0;
}
	 	   	  		  		      				  		 	//hellobig_tq


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int mod = 1e9 + 7, N = 1e5 + 10;

ll pw(ll a, ll b) {
    ll r = 1;
    for( ; b ; b >>= 1, a = a * a % mod) {
        if(b & 1) {
            r = r * a % mod;
        }
    }
    return r;
}

ll getinv(ll n) {
    return pw(n, mod - 2);
}

int n, a[N];

int main() {
	cin >> n;
	int ans = 0;
	for(int i = 1 ; i <= n ; ++ i) {
		cin >> a[i];
		for(int j = 1 ; j < i ; ++ j) {
			if(a[j] > a[i]) {
				++ ans;
			}
		}
	}
	if(ans & 1) printf("%d\n", 2 * ans - 1);
	else printf("%d\n", 2 * ans);
}


#include <bits/stdc++.h>
using namespace std;

const int maxn=3005;
int a[maxn];
double dp[maxn*maxn];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    int cnt=0;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            if(a[i]>a[j])cnt++;
        }
    }
    dp[0]=0;dp[1]=1;
    for(int i=3;i<=cnt;i++)dp[i]=4+dp[i-2];
    printf("%.6f\n",dp[cnt]);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int maxn=3005;
int a[maxn];
double dp[maxn*maxn];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    int cnt=0;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            if(a[i]>a[j])cnt++;
        }
    }
    dp[0]=0;dp[1]=1;
    for(int i=2;i<=cnt;i++)dp[i]=4+dp[i-2];
    printf("%.6f\n",dp[cnt]);
    return 0;
}


#include<bits/stdc++.h>
#define reg register int
#define il inline
#define fi first
#define se second
#define mk(a,b) make_pair(a,b)
#define numb (ch^'0')
#define pb push_back
#define solid const auto &
#define enter cout<<endl
#define pii pair<int,int>
using namespace std;
typedef long long ll;
template<class T>il void rd(T &x){
    char ch;x=0;bool fl=false;while(!isdigit(ch=getchar()))(ch=='-')&&(fl=true);
    for(x=numb;isdigit(ch=getchar());x=x*10+numb);(fl==true)&&(x=-x);}
template<class T>il void output(T x){if(x/10)output(x/10);putchar(x%10+'0');}
template<class T>il void ot(T x){if(x<0) putchar('-'),x=-x;output(x);putchar(' ');}
template<class T>il void prt(T a[],int st,int nd){for(reg i=st;i<=nd;++i) ot(a[i]);putchar('\n');}
namespace Modulo{
const int mod=998244353;
int ad(int x,int y){return (x+y)>=mod?x+y-mod:x+y;}
void inc(int &x,int y){x=ad(x,y);}
int mul(int x,int y){return (ll)x*y%mod;}
void inc2(int &x,int y){x=mul(x,y);}
int qm(int x,int y=mod-2){int ret=1;while(y){if(y&1) ret=mul(x,ret);x=mul(x,x);y>>=1;}return ret;}
template<class ...Args>il int ad(const int a,const int b,const Args &...args) {return ad(ad(a,b),args...);}
template<class ...Args>il int mul(const int a,const int b,const Args &...args) {return mul(mul(a,b),args...);}
}
// using namespace Modulo;
namespace Miracle{
const int N=3003;
int n;
int a[N];
int ct;
int main(){
    rd(n);
    for(reg i=1;i<=n;++i) rd(a[i]);
    for(reg i=1;i<=n;++i){
        for(reg j=1;j<i;++j){
            ct+=(a[j]>a[i]);
        }
    }
    ot(2*ct-(ct&1));return 0;
}

}
signed main(){
    Miracle::main();
    return 0;
}

/*
   Author: *Miracle*
*/


/**Bismillahir Rahmanir Rahim  *///{
#include <bits/stdc++.h>
using namespace std;
#define inf 1000000007
#define eps 1e-6
#define ldeps 1e-9
#define im($, _mod) if ($ >= _mod) $ -= _mod; else if ($<0) $ += _mod;
#define bug(args ...) cout << __LINE__ << ": ", err(new istringstream(string(#args)), args), cout << '\n'
inline void err(istringstream *iss) {}
template<typename T, typename ... Args> void err(istringstream *iss, const T &$val, const Args & ... args) {
    string $name; *iss >> $name; if ($name.back()==',') $name.pop_back();
    cout << $name << " = " << $val << "; ", err(iss, args ...);
}
using ll = long long; using ull = unsigned long long; using ld = long double;
const ll llinf = (1ll<<61)-1;
int n, m, K, T, Q, cn;//}
#define mxn 3005

int a[mxn];

ll mergeSort(int l, int r) {
    if (l>=r) return 0;
    int mid = (l+r)>>1;
    ll invCnt = mergeSort(l, mid)+mergeSort(mid+1, r);
    for (int i = l, j = mid+1; i<=mid || j<=r; ) {
        if (j>r || (i<=mid && a[i]<=a[j])) i++;
        else j++, invCnt += mid-i+1;
    }
    for (int i = l, j = mid+1; i<=mid || j<=r; ) {
        if (j>r || (i<=mid && a[i]<a[j])) i++;
        else j++;
    }
    inplace_merge(a+l, a+mid+1, a+r+1);
    return invCnt;
}

double dp[2];

int main() { cin.tie(NULL);

// Known observation: Adjacent swaps needed to make sorted==inversion. If a sorted pair is swapped by furik,
// inversion++, otherwise inversion--. Here in 2 steps we can come back to same state, self transition has to be handled
// separately. in jeff's move, dp[i] = i>=2 ? 2+0.5*dp[i-2]+0.5*dp[i] : 1+dp[i-1].
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    ll inversion = mergeSort(0, n-1);
    dp[0] = dp[1] = 0;
    double ans = 0;
    if (inversion&1) ans++, inversion--;
    // for (int i = 2; i <= inversion; i += 2) {
    //     ans = 4+ans;
    // }
    printf("%.9f\n", ans+inversion*2);

return 0; }


#include<bits/stdc++.h>
using namespace std;

const int maxn = 3123,mall = (maxn - 1 )* maxn / 2;

int arr[maxn];
double sta[mall],c[mall];
double anw[mall];

int main(){
    int n;
    scanf("%d",&n);
    for(int i = 1;i <= n;i++) scanf("%d",&arr[i]);
    int x = 0,all = n * ( n - 1 ) / 2;
    for(int i = 1; i <= n;i++){
        for(int j = i + 1; j <= n;j++){
            x += arr[i] > arr[j];
        }
    }
    printf("%d.000000\n", 2 * x - x % 2);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

const int maxn = 3123;

int arr[maxn];

int main(){
    int n;
    scanf("%d",&n);
    for(int i = 1;i <= n;i++) scanf("%d",&arr[i]);
    int x = 0,all = n * ( n - 1 ) / 2;
    for(int i = 1; i <= n;i++){
        for(int j = i + 1; j <= n;j++){
            x += arr[i] > arr[j];
        }
    }
    printf("%d.000000\n", 2 * x - x % 2);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int size = 3000;
int tree[size+10];

int lowBit( int x ) {
    return x & (-x);
}

void update( int x , int y ) {
    while ( x ) {
        tree[x] += y;
        x -= lowBit(x);
    }
}

int query( int x ) {
    int sum = 0;
    while ( x<=size ) {
        sum += tree[x];
        x += lowBit(x);
    }
    return sum;
}

int main() {
    int n;
    while ( cin >> n ) {
        int res = 0;
        memset( tree , 0 , sizeof(tree) );
        for ( int i = 1 ; i<=n ; ++i ) {
            int x;
            cin >> x;
            res += query( x );
            update( x , 1 );
        }
        cout << ( res*2 - (res&1) ) << endl;
    }
    return 0;
}


import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solution sol = new Solution();
        sol.solve(in, out);
        out.close();
    }

    private static class Solution {
        private void solve(InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = in.readArray(n);
            HashMap<Integer, ArrayList<Integer>> progressions = new HashMap<>();
            for (int i = 0; i < n; ++i) {
                ArrayList<Integer> l = progressions.getOrDefault(a[i], new ArrayList<>());
                l.add(i);
                progressions.put(a[i], l);
            }
            ArrayList<Pair> ans = new ArrayList<>();
            for (int key : progressions.keySet()) {
                ArrayList<Integer> aps = progressions.get(key);
                if (aps.size() == 1) {
                    ans.add(new Pair(key, 0));
                } else {
                    int diff = aps.get(1) - aps.get(0);
                    boolean fail = true;
                    for (int i = 1; i < aps.size(); ++i)
                        if (aps.get(i) - aps.get(i - 1) != diff) {
                            fail = false;
                            break;
                        }
                    if (fail)
                        ans.add(new Pair(key, diff));
                }
            }
            Collections.sort(ans);
            out.println(ans.size());
            for (int i = 0; i < ans.size(); ++i) {
                out.println(ans.get(i));
            }
        }
    }

    private static class Pair implements Comparable<Pair> {
        int first, second;

        public Pair(int first, int second) {
            this.first = first;
            this.second = second;
        }

        @Override
        public String toString() {
            return first + " " + second;
        }

        @Override
        public int compareTo(Pair o) {
            return Integer.compare(first, o.first);
        }
    }

    private static class InputReader {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        private InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        private String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        private int nextInt() {
            return Integer.parseInt(next());
        }

        private int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; ++i)
                a[i] = nextInt();
            return a;
        }
    }
}


import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    private static Scanner scanner = new Scanner(System.in);
    private static int OO = (int) 1e5 + 9;
    private static int[] dx = {0, 0, 1, -1};
    private static int[] dy = {1, -1, 0, 0};
    private static int[] num = new int[OO];

    public static void main(String[] args) {
        int n = scanner.nextInt();
        ArrayList<ArrayList<Integer>> list = new ArrayList<>(OO);
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = scanner.nextInt();
        }
        for (int i = 0; i < OO; i++) {
            list.add(new ArrayList<>());
        }
        ArrayList<Pair> answer = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            list.get(arr[i]).add(i);
        }
        for (int i = 1; i < 100001; i++) {
            if (list.get(i).size() == 0) {
                continue;
            } else if (list.get(i).size() == 1) {
                answer.add(new Pair(i, 0));
            } else {
                boolean ok = true;
                for (int j = 0; j < list.get(i).size() - 1; j++) {
                    if ((list.get(i).get(j) - list.get(i).get(j + 1)) != (list.get(i).get(0) - list.get(i).get(1))) {
                        ok = false;
                        break;
                    }
                }
                if (ok) {
                    answer.add(new Pair(i, list.get(i).get(1) - list.get(i).get(0)));
                }
            }
        }
        System.out.println(answer.size());
        for (Pair r : answer) {
            System.out.println(r.first + " " + r.second);
        }

    }

    private static class Pair implements Comparable<Pair> {
        int first;
        int second;

        Pair(int first, int second) {
            this.first = first;
            this.second = second;
        }

        @Override
        public int compareTo(Pair o) {
            return Double.compare(o.second, second);
        }
    }
}


import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    private static Scanner scanner = new Scanner(System.in);
    private static int OO = (int) 1e5 + 9;
    private static int[] dx = {0, 0, 1, -1};
    private static int[] dy = {1, -1, 0, 0};
    private static int[] num = new int[OO];

    public static void main(String[] args) {
        int n = scanner.nextInt();
        ArrayList<ArrayList<Integer>> lists = new ArrayList<>();
        ArrayList<ArrayList<Integer>> Plists = new ArrayList<>();
        ArrayList<Integer> dList = new ArrayList<>();
        int[][] arr = new int[OO][2];
        boolean ok = true;
        for (int i = 0; i < OO; i++) {
            lists.add(i, new ArrayList<>());
            Plists.add(i, new ArrayList<>());
        }
        for (int i = 0; i < n; i++) {
            int a = scanner.nextInt();
            lists.get(a).add(i);
            for (Integer integer : dList) {
                if (integer == a) {
                    ok = false;
                    break;
                }
            }
            if (ok) {
                dList.add(a);
            } else {
                ok = true;
            }
        }
        ok = true;
        for (int i = 0; i < OO; i++) {
            if (lists.get(i).size() != 0) {
                if (lists.get(i).size() == 1) {
                    Plists.get(i).add(0);
                } else {
                    int b = lists.get(i).get(1) - lists.get(i).get(0);
                    for (int j = lists.get(i).size() - 1; j > 0; j--) {
                        if (lists.get(i).get(j) - lists.get(i).get(j - 1) != b) {
                            ok = false;
                            break;
                        }
                    }
                    if (!ok) {
                        ok = true;
                    } else {
                        Plists.get(i).add(b);
                    }
                }
            }
        }
        //print
        int q = 0;
        for (int i = 0; i < OO; i++) {
            if (Plists.get(i).size() != 0) {
                for (int j = 0; j < Plists.get(i).size(); j++) {
                  //  System.out.print(Plists.get(i).get(j) + " ");

                    arr[q][0] = i;
                    arr[q][1] = Plists.get(i).get(j);
                    q += 1;
                }
               // System.out.println(" ");
            }
        }
        /*for (Integer integer : dList) {
            System.out.print(integer + " ");
        }*/
        System.out.println(q);
        for (int i = 0; i < OO; i++) {
            if (arr[i][0] != 0) {
                System.out.println(arr[i][0] + " " + arr[i][1]);
            }
        }
    }
}


import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    private static Scanner scanner = new Scanner(System.in);
    private static int OO = (int) 1e5 + 9;
    private static int[] dx = {0, 0, 1, -1};
    private static int[] dy = {1, -1, 0, 0};
    private static int[] num = new int[OO];

    public static void main(String[] args) {
        int n = scanner.nextInt(),max=0;
        ArrayList<ArrayList<Integer>> lists = new ArrayList<>();
        ArrayList<ArrayList<Integer>> Plists = new ArrayList<>();
        boolean ok = true;
        for (int i = 0; i < OO; i++) {
            lists.add(i, new ArrayList<>());
            Plists.add(i, new ArrayList<>());
        }
        for (int i = 0; i < n; i++) {
            int a = scanner.nextInt();
            if (a>max){
                max=a;
            }
            lists.get(a).add(i);
        }
        max+=1;
        int[][] arr = new int[max][2];
        for (int i = 0; i < max; i++) {
            if (lists.get(i).size() != 0) {
                if (lists.get(i).size() == 1) {
                    Plists.get(i).add(0);
                } else {
                    int b = lists.get(i).get(1) - lists.get(i).get(0);
                    for (int j = lists.get(i).size() - 1; j > 0; j--) {
                        if (lists.get(i).get(j) - lists.get(i).get(j - 1) != b) {
                            ok = false;
                            break;
                        }
                    }
                    if (!ok) {
                        ok = true;
                    } else {
                        Plists.get(i).add(b);
                    }
                }
            }
        }
        int q = 0;
        for (int i = 0; i < max; i++) {
            if (Plists.get(i).size() != 0) {
                for (int j = 0; j < Plists.get(i).size(); j++) {
                    arr[q][0] = i;
                    arr[q][1] = Plists.get(i).get(j);
                    q += 1;
                }
            }
        }
        System.out.println(q);
        for (int i = 0; i < max; i++) {
            if (arr[i][0] != 0) {
                System.out.println(arr[i][0] + " " + arr[i][1]);
            }
        }
    }
}


import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    private static Scanner scanner = new Scanner(System.in);
    private static int OO = (int) 1e5 + 9;
    private static int[] dx = {0, 0, 1, -1};
    private static int[] dy = {1, -1, 0, 0};
    private static int[] num = new int[OO];

    public static void main(String[] args) {
        int n = scanner.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = scanner.nextInt();
        }
        HashMap<Integer, ArrayList<Integer>> progressions = new HashMap<>();
        for (int i = 0; i < n; i++) {
            ArrayList<Integer> l = progressions.getOrDefault(arr[i], new ArrayList<>());
            l.add(i);
            progressions.put(arr[i], l);
        }
        ArrayList<Pair> answer = new ArrayList<>();
        for (int key : progressions.keySet()) {
            ArrayList<Integer> aps = progressions.get(key);
            if (aps.size() == 1) {
                answer.add(new Pair(key, 0));
            } else {
                int different = aps.get(1) - aps.get(0);
                boolean ok = true;
                for (int i = 1; i < aps.size(); ++i)
                    if (aps.get(i) - aps.get(i - 1) != different) {
                        ok = false;
                        break;
                    }
                if (ok) {
                    answer.add(new Pair(key, different));
                }
            }
        }
        System.out.println(answer.size());
        for (Pair r : answer) {
            System.out.println(r.first + " " + r.second);
        }

    }

    private static class Pair implements Comparable<Pair> {
        int first;
        int second;

        Pair(int first, int second) {
            this.first = first;
            this.second = second;
        }

        @Override
        public int compareTo(Pair o) {
            return Double.compare(o.second, second);
        }
    }
}


import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    private static Scanner scanner = new Scanner(System.in);
    private static int OO = (int) 1e5 + 9;
    private static int[] dx = {0, 0, 1, -1};
    private static int[] dy = {1, -1, 0, 0};
    private static int[] num = new int[OO];

    public static void main(String[] args) {
        int n = scanner.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt();
        }
        HashMap<Integer, ArrayList<Integer>> progressions = new HashMap<>();
        for (int i = 0; i < n; ++i) {
            ArrayList<Integer> l = progressions.getOrDefault(a[i], new ArrayList<>());
            l.add(i);
            progressions.put(a[i], l);
        }
        ArrayList<Pair> ans = new ArrayList<>();
        for (int key : progressions.keySet()) {
            ArrayList<Integer> aps = progressions.get(key);
            if (aps.size() == 1) {
                ans.add(new Pair(key, 0));
            } else {
                int diff = aps.get(1) - aps.get(0);
                boolean fail = true;
                for (int i = 1; i < aps.size(); ++i)
                    if (aps.get(i) - aps.get(i - 1) != diff) {
                        fail = false;
                        break;
                    }
                if (fail)
                    ans.add(new Pair(key, diff));
            }
        }
        Collections.sort(ans);
        System.out.println(ans.size());
        for (int i = 0; i < ans.size(); ++i) {
            System.out.println(ans.get(i));
        }
    }

    private static class Pair implements Comparable<Pair> {
        int first, second;

        public Pair(int first, int second) {
            this.first = first;
            this.second = second;
        }

        @Override
        public String toString() {
            return first + " " + second;
        }

        @Override
        public int compareTo(Pair o) {
            return Integer.compare(first, o.first);
        }
    }
}


//package CP.Ladder11;

import java.io.*;
import java.util.*;
import java.util.stream.IntStream;

import static java.lang.Math.*;
import static java.util.Arrays.*;

@SuppressWarnings("ALL")
public class BJeffAndPeriods {
    public static void main(String[] $) throws IOException {
        BJeffAndPeriods o = new BJeffAndPeriods();
        o.main();
        out.flush();
        out.close();
    }

    void main() throws IOException {
        long n = in.rl();
        Map<Long, ArrayList<Long>> map = new HashMap<>();
        in.r();
        for (long i = 0; i < n; i++) {
            long x = in.nl();
            map.computeIfAbsent(x, k -> new ArrayList<>()).add(i);
//            map.computeIfPresent(x, (key, val) -> map.get(x)).add(i);
        }
//        out.prln(map.toString());
        int max = IMIN;
        long x = IMIN;
        ArrayList<Pair<Long, Long>> a = new ArrayList<>();
        for (Map.Entry<Long, ArrayList<Long>> entry : map.entrySet()) {
            if (entry.getValue().size() > max) {
                max = entry.getValue().size();
                x = entry.getKey();
            }
            if (entry.getValue().size() == 1) {
                a.add(new Pair<>(entry.getKey(), (long) 0));
            } else {
                long diff = abs(entry.getValue().get(1) - entry.getValue().get(0));
                boolean ok = true;
                for (int i = 0; i < entry.getValue().size() - 1; i++) {
                    if (abs(entry.getValue().get(i) - entry.getValue().get(i + 1)) != diff) {
                        ok = false;
                    }
                }
                if (ok) a.add(new Pair<>(entry.getKey(), diff));
            }
        }
        out.prln(map.get(x).size());
        for (int i = 0; i < a.size(); i++) {
            out.prln(a.get(i).first + " " + a.get(i).second);
        }
    }

    static BufferedReader __in = new BufferedReader(new InputStreamReader(System.in));
    static PrintWriter __out = new PrintWriter(new OutputStreamWriter(System.out));
    static StringTokenizer input;
    static Random __rand = new Random();
    // constants
    static final int IBIG = 1000000007;
    static final int IMAX = 2147483647;
    static final int IMIN = -2147483648;
    static final long LMAX = 9223372036854775807L;
    static final long LMIN = -9223372036854775808L;

    //Fast Reader Class
    /*static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }*/

    //Input fxs
    static class in {
        // input
        static void r() throws IOException {
            input = new StringTokenizer(rline());
        }

        static int ri() throws IOException {
            return Integer.parseInt(rline());
        }

        static long rl() throws IOException {
            return Long.parseLong(rline());
        }

        static double rd() throws IOException {
            return Double.parseDouble(rline());
        }

        static int[] ria(int n) throws IOException {
            int[] a = new int[n];
            r();
            for (int i = 0; i < n; ++i) a[i] = ni();
            return a;
        }

        static int[] riam1(int n) throws IOException {
            int[] a = new int[n];
            r();
            for (int i = 0; i < n; ++i) a[i] = ni() - 1;
            return a;
        }

        static long[] ria1i(long n) throws IOException {
            long[] a = new long[(int) n + 1];
            r();
            for (int i = 1; i <= n; i++) a[i] = nl();
            return a;
        }

        static long[] rla(int n) throws IOException {
            long[] a = new long[n];
            r();
            for (int i = 0; i < n; ++i) a[i] = nl();
            return a;
        }

        static double[] rda(int n) throws IOException {
            double[] a = new double[n];
            r();
            for (int i = 0; i < n; ++i) a[i] = nd();
            return a;
        }

        static char[] rcha() throws IOException {
            return rline().toCharArray();
        }

        static ArrayList<Integer> riaa(int n) throws IOException {
            ArrayList<Integer> a = new ArrayList<>();
            r();
            for (int i = 0; i < n; i++) a.add(ni());
            return a;
        }

        static String rline() throws IOException {
            return __in.readLine();
        }

        static String n() {
            return input.nextToken();
        }

        static int rni() throws IOException {
            r();
            return ni();
        }

        static int ni() {
            return Integer.parseInt(n());
        }

        static long rnl() throws IOException {
            r();
            return nl();
        }

        static long nl() {
            return Long.parseLong(n());
        }

        static double rnd() throws IOException {
            r();
            return nd();
        }

        static double nd() {
            return Double.parseDouble(n());
        }

        static List<List<Integer>> rg(int n, int m) throws IOException {
            List<List<Integer>> g = GR.g(n);
            for (int i = 0; i < m; ++i) GR.c(g, rni() - 1, ni() - 1);
            return g;
        }

        static void rg(List<List<Integer>> g, int m) throws IOException {
            for (int i = 0; i < m; ++i) GR.c(g, rni() - 1, ni() - 1);
        }

        static List<List<Integer>> rdg(int n, int m) throws IOException {
            List<List<Integer>> g = GR.g(n);
            for (int i = 0; i < m; ++i) GR.cto(g, rni() - 1, ni() - 1);
            return g;
        }

        static void rdg(List<List<Integer>> g, int m) throws IOException {
            for (int i = 0; i < m; ++i) GR.cto(g, rni() - 1, ni() - 1);
        }

        static List<Set<Integer>> rsg(int n, int m) throws IOException {
            List<Set<Integer>> g = GR.sg(n);
            for (int i = 0; i < m; ++i) GR.c(g, rni() - 1, ni() - 1);
            return g;
        }

        static void rsg(List<Set<Integer>> g, int m) throws IOException {
            for (int i = 0; i < m; ++i) GR.c(g, rni() - 1, ni() - 1);
        }

        static List<Set<Integer>> rdsg(int n, int m) throws IOException {
            List<Set<Integer>> g = GR.sg(n);
            for (int i = 0; i < m; ++i) GR.cto(g, rni() - 1, ni() - 1);
            return g;
        }

        static void rdsg(List<Set<Integer>> g, int m) throws IOException {
            for (int i = 0; i < m; ++i) GR.cto(g, rni() - 1, ni() - 1);
        }

        static int[][] rim(int n, int m) throws IOException {
            int[][] a = new int[n][m];
            for (int i = 0; i < n; i++) {
                in.r();
                for (int j = 0; j < m; j++) {
                    a[i][j] = in.ni();
                }
            }
            return a;
        }
    }

    //Output fxs
    static class out {
        // output
        static void pr(int i) {
            __out.print(i);
        }

        static void prln(int i) {
            __out.println(i);
        }

        static void pr(long l) {
            __out.print(l);
        }

        static void prln(long l) {
            __out.println(l);
        }

        static void pr(double d) {
            __out.print(d);
        }

        static void prln(double d) {
            __out.println(d);
        }

        static void pr(char c) {
            __out.print(c);
        }

        static void prln(char c) {
            __out.println(c);
        }

        static void pr(char[] s) {
            __out.print(new String(s));
        }

        static void prln(char[] s) {
            __out.println(new String(s));
        }

        static void pr(String s) {
            __out.print(s);
        }

        static void prln(String s) {
            __out.println(s);
        }

        static void pr(Object o) {
            __out.print(o);
        }

        static void prln(Object o) {
            __out.println(o);
        }

        static void prln() {
            __out.println();
        }

        static void pryes() {
            prln("yes");
        }

        static void pry() {
            prln("Yes");
        }

        static void prY() {
            prln("YES");
        }

        static void prno() {
            prln("no");
        }

        static void prn() {
            prln("No");
        }

        static void prN() {
            prln("NO");
        }

        static void pryesno(boolean b) {
            prln(b ? "yes" : "no");
        }

        ;

        static void pryn(boolean b) {
            prln(b ? "Yes" : "No");
        }

        static void prYN(boolean b) {
            prln(b ? "YES" : "NO");
        }

        static void prln(int... a) {
            for (int i = 0, len = a.length - 1; i < len; pr(a[i]), pr(' '), ++i) ;
            if (a.length > 0) prln(a[a.length - 1]);
            else prln();
        }

        static void prln(long... a) {
            for (int i = 0, len = a.length - 1; i < len; pr(a[i]), pr(' '), ++i) ;
            if (a.length > 0) prln(a[a.length - 1]);
            else prln();
        }

        static void prln(double... a) {
            for (int i = 0, len = a.length - 1; i < len; pr(a[i]), pr(' '), ++i) ;
            if (a.length > 0) prln(a[a.length - 1]);
            else prln();
        }

        static <T> void prln(Collection<T> c) {
            int n = c.size() - 1;
            Iterator<T> iter = c.iterator();
            for (int i = 0; i < n; pr(iter.next()), pr(' '), ++i) ;
            if (n >= 0) prln(iter.next());
            else prln();
        }

        static void h() {
            prln("hlfd");
            flush();
        }

        static void flush() {
            __out.flush();
        }

        static void close() {
            __out.close();
        }

        static void prM(int[][] a, int n, int m) {
            for (int i = 0; i < m; i++) {
                for (int j = 0; j < n; j++)
                    out.pr(a[i][j] + " ");
                out.prln();
            }
        }
    }

    //Math fxs
    static class mathx {
        // math util
        static int minof(int a, int b, int c) {
            return min(a, min(b, c));
        }

        static int minof(int... x) {
            if (x.length == 1) return x[0];
            if (x.length == 2) return min(x[0], x[1]);
            if (x.length == 3) return min(x[0], min(x[1], x[2]));
            int min = x[0];
            for (int i = 1; i < x.length; ++i) if (x[i] < min) min = x[i];
            return min;
        }

        static long minof(long a, long b, long c) {
            return min(a, min(b, c));
        }

        static long minof(long... x) {
            if (x.length == 1) return x[0];
            if (x.length == 2) return min(x[0], x[1]);
            if (x.length == 3) return min(x[0], min(x[1], x[2]));
            long min = x[0];
            for (int i = 1; i < x.length; ++i) if (x[i] < min) min = x[i];
            return min;
        }

        static int maxof(int a, int b, int c) {
            return max(a, max(b, c));
        }

        static int maxof(int... x) {
            if (x.length == 1) return x[0];
            if (x.length == 2) return max(x[0], x[1]);
            if (x.length == 3) return max(x[0], max(x[1], x[2]));
            int max = x[0];
            for (int i = 1; i < x.length; ++i) if (x[i] > max) max = x[i];
            return max;
        }

        static long maxof(long a, long b, long c) {
            return max(a, max(b, c));
        }

        static long maxof(long... x) {
            if (x.length == 1) return x[0];
            if (x.length == 2) return max(x[0], x[1]);
            if (x.length == 3) return max(x[0], max(x[1], x[2]));
            long max = x[0];
            for (int i = 1; i < x.length; ++i) if (x[i] > max) max = x[i];
            return max;
        }

        static int powi(int a, int b) {
            if (a == 0) return 0;
            int ans = 1;
            while (b > 0) {
                if ((b & 1) > 0) ans *= a;
                a *= a;
                b >>= 1;
            }
            return ans;
        }

        static long powl(long a, int b) {
            if (a == 0) return 0;
            long ans = 1;
            while (b > 0) {
                if ((b & 1) > 0) ans *= a;
                a *= a;
                b >>= 1;
            }
            return ans;
        }

        static int fli(double d) {
            return (int) d;
        }

        static int cei(double d) {
            return (int) ceil(d);
        }

        static long fll(double d) {
            return (long) d;
        }

        static long cel(double d) {
            return (long) ceil(d);
        }

        static int gcd(int a, int b) {
            return b == 0 ? a : gcd(b, a % b);
        }

        static long gcd(long a, long b) {
            return b == 0 ? a : gcd(b, a % b);
        }

        static int lcm(int a, int b) {
            return a * b / gcd(a, b);
        }

        static long lcm(long a, long b) {
            return a * b / gcd(a, b);
        }

        static int randInt(int min, int max) {
            return __rand.nextInt(max - min + 1) + min;
        }

        static long mix(long x) {
            x += 0x9e3779b97f4a7c15L;
            x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9L;
            x = (x ^ (x >> 27)) * 0x94d049bb133111ebL;
            return x ^ (x >> 31);
        }
    }

    //Array fxs
    static class ARR {
        // array util
        static void reverse(int[] a) {
            for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {
                int swap = a[i];
                a[i] = a[n - i - 1];
                a[n - i - 1] = swap;
            }
        }

        static void reverse(long[] a) {
            for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {
                long swap = a[i];
                a[i] = a[n - i - 1];
                a[n - i - 1] = swap;
            }
        }

        static void reverse(double[] a) {
            for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {
                double swap = a[i];
                a[i] = a[n - i - 1];
                a[n - i - 1] = swap;
            }
        }

        static void reverse(char[] a) {
            for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {
                char swap = a[i];
                a[i] = a[n - i - 1];
                a[n - i - 1] = swap;
            }
        }

        static void shuffle(int[] a) {
            int n = a.length - 1;
            for (int i = 0; i < n; ++i) {
                int ind = mathx.randInt(i, n);
                int swap = a[i];
                a[i] = a[ind];
                a[ind] = swap;
            }
        }

        static void shuffle(long[] a) {
            int n = a.length - 1;
            for (int i = 0; i < n; ++i) {
                int ind = mathx.randInt(i, n);
                long swap = a[i];
                a[i] = a[ind];
                a[ind] = swap;
            }
        }

        static void shuffle(double[] a) {
            int n = a.length - 1;
            for (int i = 0; i < n; ++i) {
                int ind = mathx.randInt(i, n);
                double swap = a[i];
                a[i] = a[ind];
                a[ind] = swap;
            }
        }

        static void rsort(int[] a) {
            shuffle(a);
            sort(a);
        }

        static void rsort(long[] a) {
            shuffle(a);
            sort(a);
        }

        static void rsort(double[] a) {
            shuffle(a);
            sort(a);
        }

        static int[] copy(int[] a) {
            int[] ans = new int[a.length];
            System.arraycopy(a, 0, ans, 0, a.length);
            return ans;
        }

        static long[] copy(long[] a) {
            long[] ans = new long[a.length];
            System.arraycopy(a, 0, ans, 0, a.length);
            return ans;
        }

        static double[] copy(double[] a) {
            double[] ans = new double[a.length];
            System.arraycopy(a, 0, ans, 0, a.length);
            return ans;
        }

        static char[] copy(char[] a) {
            char[] ans = new char[a.length];
            System.arraycopy(a, 0, ans, 0, a.length);
            return ans;
        }
    }

    //Graph fxs
    static class GR {
        // graph util
        static List<List<Integer>> g(int n) {
            List<List<Integer>> g = new ArrayList<>();
            for (int i = 0; i < n; ++i) g.add(new ArrayList<>());
            return g;
        }

        static List<Set<Integer>> sg(int n) {
            List<Set<Integer>> g = new ArrayList<>();
            for (int i = 0; i < n; ++i) g.add(new HashSet<>());
            return g;
        }

        static void c(List<? extends Collection<Integer>> g, int u, int v) {
            g.get(u).add(v);
            g.get(v).add(u);
        }

        static void cto(List<? extends Collection<Integer>> g, int u, int v) {
            g.get(u).add(v);
        }

        static void dc(List<? extends Collection<Integer>> g, int u, int v) {
            g.get(u).remove(v);
            g.get(v).remove(u);
        }

        static void dcto(List<? extends Collection<Integer>> g, int u, int v) {
            g.get(u).remove(v);
        }
    }

    //Utilsx class
    static class utilX {
        static int[] subsetSum(int[] nums) {
            int M = IntStream.of(nums).sum();
            int[] m = new int[M + 10];
            for (int i = 0; i < M + 10; i++) m[i] = 0;
            m[0] = 1;
            for (int num : nums) {
                for (int j = M; j >= num; j--) {
                    m[j] |= m[j - num];
                }
            }
            return m;
        }

        static int LIS(int[] nums) {
            int[] m = new int[nums.length];
            for (int i = nums.length - 1; i >= 0; i--) {
                m[i] = 1;
                for (int j = i + 1; j < nums.length; j++) {
                    if (nums[j] > nums[i]) {
                        m[i] = max(m[i], m[j] + 1);
                    }
                }
            }
            int ans = 0;
            for (int i = 0; i < nums.length; i++) {
                ans = max(ans, m[i]);
            }
            return ans;
        }
    }

    //Pair Class
    static class Pair<F, S> {
        public final F first;
        public final S second;

        public Pair(F first, S second) {
            this.first = first;
            this.second = second;
        }

        @Override
        public boolean equals(Object o) {
            if (!(o instanceof Pair)) {
                return false;
            }
            Pair<?, ?> p = (Pair<?, ?>) o;
            return Objects.equals(p.first, first) && Objects.equals(p.second, second);
        }
    }
}