#include #include #include #include using namespace std; int main() { int N, i; cin >> N; if (N == 1) { cout << 0 << endl; return 0; } vector P(N); int take = 0; int suzuki = 0; int I; for (i = 0; i < N; i++) { cin >> P[i]; if (P[i] == N) { I = i; } } for (i = 0; i < N; i++) { if (i != I) { take += i + 1; } else { suzuki += i + 1; } } cout << take - suzuki << endl; return 0; }