#include<iostream> #include<algorithm> #include<vector> using namespace std; vector < vector <int> > number; int cmp(int s, int w) { return s<w; } int main(void) { int n, i, j, ans = 0; cin>>n; number.resize(2); number[0].resize(n + 5), number[1].resize(n + 5); for(i = 0; i<n; i++){ cin>>number[0][i]; number[1][i] = number[0][i]; } sort(number[1].begin(), number[1].begin() + n, cmp); for(i = 0; i<n; i++){ for(j = i + 1; j<n; j++){ if(number[0][i] != number[1][i] && number[0][j] != number[1][j] && number[0][i] == number[1][j] && number[1][i] == number[0][j]){ number[0][i] = number[1][i]; number[0][j] = number[1][j]; ans++; break; } } } for(i = 0; i<n; i++){ for(j = i + 1; j<n; j++){ if(number[0][i] != number[1][i] && number[0][j] != number[1][j] && number[1][i] == number[0][j]){ number[0][j] = number[0][i]; number[0][i] = number[1][i]; ans++; break; } } } cout<<ans; return 0; }