#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define pii pair<int, int>
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
#ifdef CB
freopen("be2.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
#endif
int N;
cin >> N;
vector<int> v(N);
for (int i = 0; i < N; i++) {
cin >> v[i];
}
map<int, int> m;
int ans = 0;
for (int i = 0; i < N; i++) {
v[i] = (v[i] + ans) % N;
if (!m.contains(v[i])) {
auto t = m.insert({v[i], ans}).first;
if (t != m.begin() && t->first - t->second <= prev(t)->first - prev(t)->second) {
t = m.erase(t);
}
}
auto t = m.upper_bound(i);
if (t == m.begin()) {
ans += max(0ll, N + i - m.rbegin()->first - (ans - m.rbegin()->second));
}
else {
ans += max(0ll, i - prev(t)->first - (ans - prev(t)->second));
}
}
cout << ans << '\n';
return 0;
}
exit status 1
main.cpp: In function 'int main()':
main.cpp:27:24: error: 'class std::map<long long int, long long int>' has no member named 'contains'
27 | if (!m.contains(v[i])) {
| ^~~~~~~~
Exited with error status 1