first solution for minavgtwoslice