import java.io.*;
import java.util.*;
public class Main
{
  public static void main(String args[])throws IOException
  {
    InputStreamReader read = new InputStreamReader(System.in);
    BufferedReader in = new BufferedReader(read);
    String line[]=in.readLine().trim().split(" ");
    int n=Integer.parseInt(line[0]);
    int m=Integer.parseInt(line[1]);
    String arr[]=in.readLine().trim().split(" ");
    int i;
    int a[]=new int[m];
    int sum[]=new int[m];
    for(i=0;i<m;i++)
    {
        a[i]=Integer.parseInt(arr[i]);
    }
    sum[0]=a[0];
    for(i=1;i<m;i++)
    {
        sum[i]=sum[i-1]+a[i];
    }
    int ans=n-sum[m-1];
    if(ans>=0)
    System.out.println(ans);
    else
    System.out.println("-1");
  }
} import java.io.*; io.* java import java.util.*; util.* java public class Main
{
  public static void main(String args[])throws IOException
  {
    InputStreamReader read = new InputStreamReader(System.in);
    BufferedReader in = new BufferedReader(read);
    String line[]=in.readLine().trim().split(" ");
    int n=Integer.parseInt(line[0]);
    int m=Integer.parseInt(line[1]);
    String arr[]=in.readLine().trim().split(" ");
    int i;
    int a[]=new int[m];
    int sum[]=new int[m];
    for(i=0;i<m;i++)
    {
        a[i]=Integer.parseInt(arr[i]);
    }
    sum[0]=a[0];
    for(i=1;i<m;i++)
    {
        sum[i]=sum[i-1]+a[i];
    }
    int ans=n-sum[m-1];
    if(ans>=0)
    System.out.println(ans);
    else
    System.out.println("-1");
  }
} Main public static void main(String args[])throws IOException
  {
    InputStreamReader read = new InputStreamReader(System.in);
    BufferedReader in = new BufferedReader(read);
    String line[]=in.readLine().trim().split(" ");
    int n=Integer.parseInt(line[0]);
    int m=Integer.parseInt(line[1]);
    String arr[]=in.readLine().trim().split(" ");
    int i;
    int a[]=new int[m];
    int sum[]=new int[m];
    for(i=0;i<m;i++)
    {
        a[i]=Integer.parseInt(arr[i]);
    }
    sum[0]=a[0];
    for(i=1;i<m;i++)
    {
        sum[i]=sum[i-1]+a[i];
    }
    int ans=n-sum[m-1];
    if(ans>=0)
    System.out.println(ans);
    else
    System.out.println("-1");
  } main {
    InputStreamReader read = new InputStreamReader(System.in);
    BufferedReader in = new BufferedReader(read);
    String line[]=in.readLine().trim().split(" ");
    int n=Integer.parseInt(line[0]);
    int m=Integer.parseInt(line[1]);
    String arr[]=in.readLine().trim().split(" ");
    int i;
    int a[]=new int[m];
    int sum[]=new int[m];
    for(i=0;i<m;i++)
    {
        a[i]=Integer.parseInt(arr[i]);
    }
    sum[0]=a[0];
    for(i=1;i<m;i++)
    {
        sum[i]=sum[i-1]+a[i];
    }
    int ans=n-sum[m-1];
    if(ans>=0)
    System.out.println(ans);
    else
    System.out.println("-1");
  } InputStreamReader read = new InputStreamReader(System.in); read new InputStreamReader(System.in) BufferedReader in = new BufferedReader(read); in new BufferedReader(read) String line[]=in.readLine().trim().split(" "); line in.readLine().trim().split(" ") in.readLine().trim().split in.readLine().trim() in.readLine().trim in.readLine() in.readLine in " " int n=Integer.parseInt(line[0]); n Integer.parseInt(line[0]) Integer.parseInt Integer line[0] line 0 int m=Integer.parseInt(line[1]); m Integer.parseInt(line[1]) Integer.parseInt Integer line[1] line 1 String arr[]=in.readLine().trim().split(" "); arr in.readLine().trim().split(" ") in.readLine().trim().split in.readLine().trim() in.readLine().trim in.readLine() in.readLine in " " int i; i int a[]=new int[m]; a new int[m] m int sum[]=new int[m]; sum new int[m] m for(i=0;i<m;i++)
    {
        a[i]=Integer.parseInt(arr[i]);
    } i=0; i=0 i 0 i<m i m i++ i++ i {
        a[i]=Integer.parseInt(arr[i]);
    } {
        a[i]=Integer.parseInt(arr[i]);
    } a[i]=Integer.parseInt(arr[i]) a[i] a i Integer.parseInt(arr[i]) Integer.parseInt Integer arr[i] arr i sum[0]=a[0] sum[0] sum 0 a[0] a 0 for(i=1;i<m;i++)
    {
        sum[i]=sum[i-1]+a[i];
    } i=1; i=1 i 1 i<m i m i++ i++ i {
        sum[i]=sum[i-1]+a[i];
    } {
        sum[i]=sum[i-1]+a[i];
    } sum[i]=sum[i-1]+a[i] sum[i] sum i sum[i-1]+a[i] sum[i-1] sum i-1 i 1 a[i] a i int ans=n-sum[m-1]; ans n-sum[m-1] n sum[m-1] sum m-1 m 1 if(ans>=0)
    System.out.println(ans);
    else
    System.out.println("-1"); ans>=0 ans 0 System.out.println(ans) System.out.println System.out System System.out ans System.out.println("-1") System.out.println System.out System System.out "-1" String args[] args public class Main
{
  public static void main(String args[])throws IOException
  {
    InputStreamReader read = new InputStreamReader(System.in);
    BufferedReader in = new BufferedReader(read);
    String line[]=in.readLine().trim().split(" ");
    int n=Integer.parseInt(line[0]);
    int m=Integer.parseInt(line[1]);
    String arr[]=in.readLine().trim().split(" ");
    int i;
    int a[]=new int[m];
    int sum[]=new int[m];
    for(i=0;i<m;i++)
    {
        a[i]=Integer.parseInt(arr[i]);
    }
    sum[0]=a[0];
    for(i=1;i<m;i++)
    {
        sum[i]=sum[i-1]+a[i];
    }
    int ans=n-sum[m-1];
    if(ans>=0)
    System.out.println(ans);
    else
    System.out.println("-1");
  }
} public class Main
{
  public static void main(String args[])throws IOException
  {
    InputStreamReader read = new InputStreamReader(System.in);
    BufferedReader in = new BufferedReader(read);
    String line[]=in.readLine().trim().split(" ");
    int n=Integer.parseInt(line[0]);
    int m=Integer.parseInt(line[1]);
    String arr[]=in.readLine().trim().split(" ");
    int i;
    int a[]=new int[m];
    int sum[]=new int[m];
    for(i=0;i<m;i++)
    {
        a[i]=Integer.parseInt(arr[i]);
    }
    sum[0]=a[0];
    for(i=1;i<m;i++)
    {
        sum[i]=sum[i-1]+a[i];
    }
    int ans=n-sum[m-1];
    if(ans>=0)
    System.out.println(ans);
    else
    System.out.println("-1");
  }
} Main
import java.io.*;
import java.util.*;
public class Main
{
  public static void main(String args[])throws IOException
  {
    InputStreamReader read = new InputStreamReader(System.in);
    BufferedReader in = new BufferedReader(read);
    String line[]=in.readLine().trim().split(" ");
    int n=Integer.parseInt(line[0]);
    int m=Integer.parseInt(line[1]);
    String arr[]=in.readLine().trim().split(" ");
    int i;
    int a[]=new int[m];
    int sum[]=new int[m];
    for(i=0;i<m;i++)
    {
        a[i]=Integer.parseInt(arr[i]);
    }
    sum[0]=a[0];
    for(i=1;i<m;i++)
    {
        sum[i]=sum[i-1]+a[i];
    }
    int ans=n-sum[m-1];
    if(ans>=0)
    System.out.println(ans);
    else
    System.out.println("-1");
  }
}