#include #include #include int main(){ int n, m, *d, *r, result=10000000; int i,buff; int left,right; scanf("%d %d",&n,&m); d=(int*)malloc(sizeof(int)*m); r=(int*)malloc(sizeof(int)*(m-n+1)); for(i=0;i0)?(left=0):(left = -d[i]); (d[i+n-1]<0)?(right=0):(right=d[i+n-1]); r[i]=fmin(2*left+right,2*right+left); } for(i=0;i