import std.stdio, std.string, std.algorithm, std.conv, std.array, std.math, std.container, std.range;

void main(){
  auto nk = readln.split.map!(to!int);
  auto xs = readln.split.map!(to!int);
  auto n=nk[0], k=nk[1];
  auto cur=int.max;
  foreach(i;0..n-k+1){
    int res;
    auto from = xs[i];
    auto to = xs[i+k-1];
    if(from*to>=0)
    {
      res=max(-from, to);
    }
    else
    {
      res=to-from+min(-from,to);
    }
    if(res<cur)cur=res;
  }
  writeln(cur);
}