/** * @author SCaffrey (srius.caffrey@gmail.com) * @date 2015-11-28 18:58:47 * @copyright MIT */ #include // NOLINT #include // NOLINT #include // NOLINT #define x1 x11 #define y1 y11 #define f(x, y, z) for (int x = (y), __ = (z); x < __; ++x) #define g(x, y, z) for (int x = (y), __ = (z); x <= __; ++x) #define fd(x, y, z) for (int x = (y), __ = (z); x > __; --x) #define gd(x, y, z) for (int x = (y), __ = (z); x >= __; --x) #ifdef WIN32 #define LLD "%I64d" #define LLU "%I64u" #else #define LLD "%lld" #define LLU "%llu" #endif typedef long long LL;// NOLINT typedef long double real; const double INF = 1e100; const int oo = ~0u >> 2; const double pi = acos(-1.0); const double EPS = 1e-8; const int MAXN = 100033; LL n; LL a[MAXN]; LL d[MAXN]; LL ans, mn, tee; int main() { #ifdef LOCAL freopen("a.in", "r", stdin); freopen("a.out", "w", stdout); #endif while (~scanf(LLD, &n)) { memset(d, 0, sizeof d); ans = 0; g(i, 1, n) { scanf(LLD, a + i); d[i] = ((LL)1890 * a[i] + 143) % 10007; // printf(LLD" ", d[i]); ans += a[i]; d[i] += d[i - 1] - a[i]; } mn = ~0u >> 2; // puts(""); tee = 0; g(i, 0, n) { if (d[i] < mn) mn = d[i]; if (d[i] - mn > tee) tee = d[i] - mn; } if (tee < 0) tee = 0; // printf("%lld %lld\n", ans, tee); printf(LLD"\n", ans + tee); } #ifdef LOCAL fclose(stdin); fclose(stdout); #endif return 0; }