define _CRT_SECURE_NO_DEPRECATE
include<iostream>
include<stdio.h>
include<string.h>
include<cstring>
using namespace std;
long long num[120000], dp[120000], mk[120000];
long long maxx(long long x, long long y)
{
return x > y ? x : y;
}
int main()
{
int n, m, i, j;
while (~scanf("%d %d", &m, &n))
{
for (i = 1; i <= n; i++)
scanf("%I64d", &num[i]);
long long max;
for (i = 1; i <= m; i++)
{
max = -0x7ffffff;
for (j = i; j <= n; j++)
{
if (i == j) dp[j] = mk[j - 1] + num[j];
else
dp[j] = maxx(dp[j - 1], mk[j - 1]) + num[j];
mk[j - 1] = max;
if (max < dp[j])max = dp[j];
}
}
cout<<max;
memset(dp, 0, sizeof(dp));
memset(mk, 0, sizeof(mk));
}
}