description: You are given a digital clock with n digits. Each digit shows an integer from 0 to 9, so the whole clock shows an integer from 0 to 10^n-1. The clock will show leading zeroes if the number is smaller than 10^{n-1}.
  
  You want the clock to show 0 with as few operations as possible. In an operation, you can do one of the following: 
  
    * decrease the number on the clock by 1, or 
    * swap two digits (you can choose which digits to swap, and they don't have to be adjacent). 
  
  
  
  Your task is to determine the minimum number of operations needed to make the clock show 0.
  
  Input
  
  Each test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^3).
  
  The first line of each test case contains a single integer n (1 ≤ n ≤ 100) — number of digits on the clock.
  
  The second line of each test case contains a string of n digits s_1, s_2, …, s_n (0 ≤ s_1, s_2, …, s_n ≤ 9) — the number on the clock.
  
  Note: If the number is smaller than 10^{n-1} the clock will show leading zeroes.
  
  Output
  
  For each test case, print one integer: the minimum number of operations needed to make the clock show 0.
  
  Example
  
  Input
  
  
  7
  3
  007
  4
  1000
  5
  00000
  3
  103
  4
  2020
  9
  123456789
  30
  001678294039710047203946100020
  
  
  Output
  
  
  7
  2
  0
  5
  6
  53
  115
  
  Note
  
  In the first example, it's optimal to just decrease the number 7 times.
  
  In the second example, we can first swap the first and last position and then decrease the number by 1.
  
  In the third example, the clock already shows 0, so we don't have to perform any operations.
solution: import java.util.*;
  import java.lang.*;
  import java.io.*;
  
  public class Main
  {
      //static Scanner input= new Scanner();
      static FastReader input=new FastReader();
      //static UltraFastReader input = new UltraFastReader();
      static BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));
      // Output format => out.append("Your Data")+"\n");
      
      
      
  	public static void main (String[] args) throws java.lang.Exception
  	{
  		// your code goes here
  		// Output format => out.append("Your Data")+"\n");
  
  		int t = input.nextInt();
  		while(t-->0){
  		   
  		    int n = input.nextInt();
  		    char [] arr = input.next().toCharArray();
  		    long res = 0;
  		    for(int i=0;i<n;i++){
  		        if(arr[i]>'0'){
  		            res += (arr[i]-'0');
  		            if(i!=n-1){
  		                res += 1;
  		            }
  		        }
  		    }
  		    
  		    out.append(res+"\n");
  		}
  		
  		out.flush();
  		out.close();
  	}
  	
  	public static ArrayList<LinkedList<Integer>> createUndirectedGraph(int n, int m) throws IOException{
          //This function will create graph with n nodes and m edges.
          // It can also create a undirected tree if you pass value m as n-1
          ArrayList<LinkedList<Integer>> graph = new ArrayList<>();
          for(int i=0;i<=n;i++){
              graph.add(new LinkedList<>());
          }
          
          for(int i=1;i<=m;i++){
              int u = input.nextInt();
              int v= input.nextInt();
                  graph.get(u).add(v);
                  graph.get(v).add(u);
          }
          
          return graph;
      }
  	
  	
  	static void merge(int arr[], int l, int m, int r)
      {
          // Find sizes of two subarrays to be merged
          int n1 = m - l + 1;
          int n2 = r - m;
   
          /* Create temp arrays */
          int L[] = new int[n1];
          int R[] = new int[n2];
   
          /*Copy data to temp arrays*/
          for (int i = 0; i < n1; ++i)
              L[i] = arr[l + i];
          for (int j = 0; j < n2; ++j)
              R[j] = arr[m + 1 + j];
   
          /* Merge the temp arrays */
   
          // Initial indexes of first and second subarrays
          int i = 0, j = 0;
   
          // Initial index of merged subarry array
          int k = l;
          while (i < n1 && j < n2) {
              if (L[i] <= R[j]) {
                  arr[k] = L[i];
                  i++;
              }
              else {
                  arr[k] = R[j];
                  j++;
              }
              k++;
          }
   
          /* Copy remaining elements of L[] if any */
          while (i < n1) {
              arr[k] = L[i];
              i++;
              k++;
          }
   
          /* Copy remaining elements of R[] if any */
          while (j < n2) {
              arr[k] = R[j];
              j++;
              k++;
          }
      }
   
      // Main function that sorts arr[l..r] using
      // merge()
      static void mergeSort(int arr[], int l, int r)
      {
          if (l < r) {
              // Find the middle point
              int m =l+ (r-l)/2;
   
              // Sort first and second halves
              mergeSort(arr, l, m);
              mergeSort(arr, m + 1, r);
   
              // Merge the sorted halves
              merge(arr, l, m, r);
          }
      }
  	
  	public static int modPower(int x, int y, int p)
    {
      int res = 1; // Initialize result
   
      x = x % p; // Update x if it is more than or
      // equal to p
   
      if (x == 0)
        return 0; // In case x is divisible by p;
   
      while (y > 0)
      {
   
        // If y is odd, multiply x with result
        if ((y & 1) != 0)
          res = (res * x) % p;
   
        // y must be even now
        y = y >> 1; // y = y/2
        x = (x * x) % p;
      }
      return res;
    }
  	
  	 public static LinkedList<Integer> getDivisors(int n){
          LinkedList <Integer> res = new LinkedList<>();
          for(int i=1;i*i<=n;i++){
              if(n%i==0){
                  res.add(i);
                  if(i*i!=n){
                      res.add(n/i);
                  }
              }
          }
          return res;
      }
      
      
      public static void printLL(LinkedList<Integer> ll) throws IOException{
          out.append("{");
          for(int i:ll){
              out.append(i+" ");
          }
          out.append("}\n");
      }
      
      public static boolean isPrime(int n) throws IOException{
          for(int i=2;i*i<=n;i++){
              if(n%i==0){
                  return false;
              }
          }
          return true;
      }
  	
  	
  	//// Fast Reader Start
  	static class FastReader
      {
          BufferedReader br;
          StringTokenizer st;
          public FastReader()
          {
              br = new BufferedReader(new InputStreamReader(System.in));
          }
          String next()
          {
              while (st == null || !st.hasMoreElements())
              {
                  try
                  {
                      st = new StringTokenizer(br.readLine());
                  }
                  catch (IOException e)
                  {
                      e.printStackTrace();
                  }
              }
              return st.nextToken();
          }
          
          public String [] nextStrings(int n) throws IOException{
              String [] res = new String[n];
              for(int i=0;i<n;i++){
                  res[i] = next();
              }
              return res;
          }
          
          int nextInt()
          {
              return Integer.parseInt(next());
          }
          
          public int [] nextInts(int n) throws IOException{
              int [] res = new int[n];
              for(int i=0;i<n;i++){
                  res[i] = input.nextInt();
              }
              return res;
          }
          
          long nextLong()
          {
              return Long.parseLong(next());
          }
          
          public long [] nextLongs(int n) throws IOException{
              long [] res = new long[n];
              for(int i=0;i<n;i++){
                  res[i] = input.nextLong();
              }
              return res;
          }
          
          double nextDouble()
          {
              return Double.parseDouble(next());
          }
          
          public double [] nextDoubles(int n) throws IOException{
              double [] res = new double[n];
              for(int i=0;i<n;i++){
                  res[i] = input.nextDouble();
              }
              return res;
          }
          
          String nextLine()
          {
              String str="";
              try
              {
                  str=br.readLine();
              }
              catch (IOException e)
              {
                  e.printStackTrace();
              }
              return str;
          }
      }
      
      //// Fast Reader End
      
      
      //// Ultra Fast Reader Start
      
      static class UltraFastReader {
          final private int BUFFER_SIZE = 1 << 16;
          private DataInputStream din;
          private byte[] buffer;
          private int bufferPointer, bytesRead;
   
          public UltraFastReader()
          {
              din = new DataInputStream(System.in);
              buffer = new byte[BUFFER_SIZE];
              bufferPointer = bytesRead = 0;
          }
   
          public UltraFastReader(String file_name) throws IOException
          {
              din = new DataInputStream(
                  new FileInputStream(file_name));
              buffer = new byte[BUFFER_SIZE];
              bufferPointer = bytesRead = 0;
          }
   
          public String readLine() throws IOException
          {
              byte[] buf = new byte[64]; // line length
              int cnt = 0, c;
              while ((c = read()) != -1) {
                  if (c == '\n') {
                      if (cnt != 0) {
                          break;
                      }
                      else {
                          continue;
                      }
                  }
                  buf[cnt++] = (byte)c;
              }
              return new String(buf, 0, cnt);
          }
   
          public int nextInt() throws IOException
          {
              int ret = 0;
              byte c = read();
              while (c <= ' ') {
                  c = read();
              }
              boolean neg = (c == '-');
              if (neg)
                  c = read();
              do {
                  ret = ret * 10 + c - '0';
              } while ((c = read()) >= '0' && c <= '9');
   
              if (neg)
                  return -ret;
              return ret;
          }
          
          public int [] nextInts(int n) throws IOException{
              int [] res = new int[n];
              for(int i=0;i<n;i++){
                  res[i] = input.nextInt();
              }
              return res;
          }
   
          public long nextLong() throws IOException
          {
              long ret = 0;
              byte c = read();
              while (c <= ' ')
                  c = read();
              boolean neg = (c == '-');
              if (neg)
                  c = read();
              do {
                  ret = ret * 10 + c - '0';
              } while ((c = read()) >= '0' && c <= '9');
              if (neg)
                  return -ret;
              return ret;
          }
          
           public long [] nextLongs(int n) throws IOException{
              long [] res = new long[n];
              for(int i=0;i<n;i++){
                  res[i] = input.nextLong();
              }
              return res;
          }
   
          public double nextDouble() throws IOException
          {
              double ret = 0, div = 1;
              byte c = read();
              while (c <= ' ')
                  c = read();
              boolean neg = (c == '-');
              if (neg)
                  c = read();
   
              do {
                  ret = ret * 10 + c - '0';
              } while ((c = read()) >= '0' && c <= '9');
   
              if (c == '.') {
                  while ((c = read()) >= '0' && c <= '9') {
                      ret += (c - '0') / (div *= 10);
                  }
              }
   
              if (neg)
                  return -ret;
              return ret;
          }
          
           public double [] nextDoubles(int n) throws IOException{
              double [] res = new double[n];
              for(int i=0;i<n;i++){
                  res[i] = input.nextDouble();
              }
              return res;
          }
   
          private void fillBuffer() throws IOException
          {
              bytesRead = din.read(buffer, bufferPointer = 0,
                                   BUFFER_SIZE);
              if (bytesRead == -1)
                  buffer[0] = -1;
          }
   
          private byte read() throws IOException
          {
              if (bufferPointer == bytesRead)
                  fillBuffer();
              return buffer[bufferPointer++];
          }
   
          public void close() throws IOException
          {
              if (din == null)
                  return;
              din.close();
          }
      }
      //// Ultra Fast Read er End
      
  }