#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
long long n, k, sum;
long long a[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i] *= -1;
    sum += a[i];
  }
  long long best = 0, now = 0;
  for (int i = 0; i < n; i++) {
    now += a[i];
    if (now < 0) now = 0;
    best = max(best, now);
  }
  cout << best - sum;
  return 0;
}
