#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef pair pii; typedef unsigned long long ull; typedef long long ll; typedef vector vi; #define xx first #define yy second #define rep(i, a, n) for (int i = a; i < n; i++) #define sa(n) scanf("%d", &(n)) #define vep(c) for(decltype((c).begin()) it = (c).begin(); it != (c).end(); it++) const int mod = int(1e4) + 7, INF = 0x3fffffff, maxn = 1e5 + 12; int n, m, T, a[maxn], b[maxn]; int change(int x) { return -(x - (1890 * x + 143) % 10007); } int maxs(int a[], int len) { int maxsum, maxhere; maxsum = maxhere = a[0]; //初始化最大和为a【0】 for (int i=1; i maxsum) { maxsum = maxhere; //更新最大连续子序列和 } } return maxsum; } int main(void) { while (~sa(n)) { int sum = 0; rep (i, 0, n) { sa(a[i]); sum += a[i]; b[i] = change(a[i]); //cout << b[i] << endl; } int t = maxs(b, n); printf("%d\n", sum + (t > 0 ? t : 0)); } return 0; } /* int n, h, v[2222]; double p; map, double> dp[2222][2222]; int getid(int x) { return lower_bound(v, v + n, x) - v + 1; } double dfs(int l, int r, int lf, int rf) { int li = getid(l), ri = getid(r); if (dp[li][ri].count(make_pair(lf, rf))) return dp[li][ri][make_pair(lf, rf)]; if (l > r) return 0; double ret = 0.0; //左边的树倒 ret += p * 0.5 * (min(h, v[l] - lf) + dfs(l + 1, r, v[l], rf)); int x = l + 1; while (v[x] < v[x - 1] + h && x <= r) x++; x--; ret += (1 - p) * 0.5 * (min(v[x] - v[l] + h, rf - v[l]) + dfs(x + 1, r, v[x] + h, rf)); //右边的树倒 ret += (1 - p) * 0.5 * (min(h, rf - v[r]) + dfs(l, r - 1, lf, v[r])); x = r - 1; while (v[x] > v[x - 1] - h && x >= l) x--; x++; ret += p * 0.5 * (min(v[r] - v[x] + h, v[r] - lf) + dfs(l, x - 1, lf, v[x] - h)); return dp[li][ri][make_pair(lf, rf)] = ret; } int main(void) { sa(n), sa(h); scanf("%lf", &p); rep (i, 0, n) sa(v[i]); sort(v, v + n); printf("%.15f\n", dfs(0, n - 1, -INF, INF)); return 0; }*/