func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 500010, inf = 1e9 + 233;   int n;   long long a[maxn];   map<long long, long long> f;   template <typename T>   inline void read(T &k) {     int f = 1;     k = 0;     char c = getchar();     while (c <  0  || c >  9 ) c ==  -  && (f = -1), c = getchar();     while (c <=  9  && c >=  0 ) k = k * 10 + c -  0 , c = getchar();     k *= f;   }   int main() {     read(n);     for (int i = 1; i <= n; i++) read(a[i]);     f[a[1] - 1] = 0;     for (int i = 1; i <= n; i++) {       for (map<long long, long long>::reverse_iterator j = f.rbegin();            j != f.rend(); j++) {         long long w = j->first;         if (a[i] > w)           break;         else {           f[w % a[i]] =               max(f[w % a[i]], j->second + 1ll * (i - 1) * (w - w % a[i]));           f[a[i] - 1] =               max(f[a[i] - 1],                   j->second + 1ll * (i - 1) * ((w - (a[i] - 1)) / a[i] * a[i]));         }       }       f.erase(f.lower_bound(a[i]), f.end());     }     long long ans = 0;     for (map<long long, long long>::reverse_iterator j = f.rbegin();          j != f.rend(); j++)       ans = max(ans, j->second + 1ll * n * j->first);     printf( %lld n , ans);   }   