import java.util.Scanner; public class Main { public static void main(String args[]){ Scanner stdIn = new Scanner(System.in); int n = stdIn.nextInt(); //int b = stdIn.nextInt(); long p[] = new long[n]; //String s = stdIn.next(); //char c[] = s.toCharArray(); long sum = 1; //boolean flag = true; for(int i = 0; i < n; i++){ sum *= stdIn.nextInt(); } while(true){ String s = String.valueOf(sum); char c[] = s.toCharArray(); sum = 0; for(int i = 0; i < s.length(); i++){ sum += c[i] - 48; } if(sum <= 9){ break; } } System.out.println(sum); //System.out.println(); //System.out.print(); } }