func_code_string: #include <bits/stdc++.h>   using i64 = long long;   template <typename _Tp>   inline void chkMax(_Tp &x, const _Tp &y) {     (x < y) and (x = y);   }   namespace IOManager {   constexpr int FILESZ = 131072;   char buf[FILESZ];   const char *ibuf = buf, *tbuf = buf;   struct IOManager {     inline char gc() {       return (ibuf == tbuf) and                      (tbuf = (ibuf = buf) + fread(buf, 1, FILESZ, stdin),                       ibuf == tbuf)                  ? EOF                  : *ibuf++;     }     template <typename _Tp>     inline operator _Tp() {       _Tp s = 0u;       char c = gc();       for (; c < 48; c = gc())         ;       for (; c > 47; c = gc()) s = (_Tp)(s * 10u + c - 48u);       return s;     }   };   }  // namespace IOManager   IOManager::IOManager io;   int main() {     static std::map<i64, i64> f;     const int n = io;     for (int i = 1; i <= n; ++i) {       const i64 a = io;       if (i == 1) f[a - 1] = 0;       for (auto it = f.rbegin(); it not_eq f.rend() and it->first >= a; ++it) {         const i64 v = it->first;         chkMax(f[v % a], it->second + (v - v % a) * (i - 1ll));         chkMax(f[a - 1], it->second + ((v - a + 1ll) / a * a) * (i - 1ll));       }       f.erase(f.lower_bound(a), f.end());     }     i64 ans = 0;     for (const auto it : f) chkMax(ans, it.second + it.first * n);     printf( %lld n , ans);     return 0;   }   