#include<stdio.h>
int main()
{
	long long tc;
	scanf("%lld",&tc);
	long long input,sum = 0,sementara;
	int countO,flag = 1,flagO = 1,flags = 1;
	for(int i = 0;i<tc;i++)
	{
		scanf("%lld",&input);
		sum += input;
		sementara = input;
		while(sementara != 0)
		{
			if(sementara % 10 == 0) countO++;
			sementara /= 10;
		}
		if(countO > 18) flags = 0;
		if(input == 0)
		{
			flagO = 0;
		}
		if(sum > 1000000000000000000 || sum < 0) 
		{
			flag = 0;
		}
	}
	if(flagO == 0) printf("0\n");
	else if(flags == 0) printf("-1\n");
	else if(flag == 0) printf("-1\n");
	else{
		printf("%lld",sum);
	}
}