#include <stdio.h>
#include <stdlib.h>

int main() 
{
    int i,m,n,h[n];
    int s;
    s=0;
    
	scanf("%d%d",&m,&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&h[i]);
		s = s+ h[i];
		}	
	if(s>m)
	  {
	  	 if(s-m>0)
	  	   printf("%d\n he can safely spend %d days hanging out.",s-m,s-m);
	  	else
	  	   printf("0\nHe can finish his assignments, but he will have no time to hang out.");
	  }
	else 
	   printf("-1\nHe cannot finish his assignments.");
	return 0;
}
