func_code_string: #include <bits/stdc++.h>   using namespace std;   long long read() {     char ch;     for (ch = getchar(); ch <  0  || ch >  9 ; ch = getchar())       ;     long long x = ch -  0 ;     for (ch = getchar(); ch >=  0  && ch <=  9 ; ch = getchar())       x = x * 10 + ch -  0 ;     return x;   }   const int N = 2 * 1e5 + 5;   struct node {     long long j, k;     node(long long _j = 0, long long _k = 0) {       j = _j;       k = _k;     }     friend bool operator<(node x, node y) {       return x.j > y.j || x.j == y.j && x.k > y.k;     }   };   set<node> f;   long long a[N];   int main() {     int n = read();     for (int i = 1; i <= n; i++) a[i] = read();     f.insert(node(a[1] - 1, 0));     for (int i = 1; i <= n - 1; i++) {       long long m = a[i + 1], Mx = 0;       bool pty = 0;       while (1) {         set<node>::iterator pos = f.begin();         long long j = (*pos).j, k = (*pos).k;         if (j < m) break;         pty = 1;         Mx = max(Mx, k + (long long)i * ((j + 1) / m * m - m));         f.insert(node(j % m, k + (long long)i * (j - j % m)));         f.erase(pos);       }       if (pty) f.insert(node(m - 1, Mx));     }     long long ans = 0;     for (set<node>::iterator pos = f.begin(); pos != f.end(); pos++) {       long long j = (*pos).j, k = (*pos).k;       ans = max(ans, k + (long long)j * n);     }     printf( %I64d n , ans);   }   