#include <stdio.h>
#include <string.h>
#include <math.h>
 
int main(void){
  	char str[1000];
	char *data;
  	int num[100], input, mole;
  	double sum = 1, oversum = 0;
  	mole = pow(10, 9);
  
	fgets(str, sizeof(str), stdin);
  	sscanf(str, "%d", &input);
	fgets(str, sizeof(str), stdin);
	data = strtok(str, " ");
  	sscanf(data, "%d", &num[0]);
  	sum = sum * num[0];
   	oversum = oversum * num[0];
  	for(int i = 1; i < input; i++){
		data = strtok(NULL, " ");
  		sscanf(data, "%d", &num[i]);
       	/*sum = sum * num[i];
      	oversum = oversum * num[i];
      	if(sum  > pow(10, 9)){*/
          oversum += sum * num[i] / mole;
          sum = fmod(sum * num[i], mole);
        //}
    }
  	
  	if(oversum >  pow(10, 9) || sum < 0){
			sum = -1;
    }
  	if( sum != -1 && oversum != 0 ){
		printf("%.0lf%09.0lf\n", oversum, sum);
    } else {
      	printf("%.0lf\n", sum);
    }
  	
  	return 0;
}