Start: Jun, 27, 2019 08:30:00
2019年度暑期短学期第二天
End: Jun, 27, 2019 11:30:00
Time elapsed:
Time remaining:

Problem_ID: H
Result: Accepted
Time: 6ms
Memory: 1728kB
Author: 2018212212236
In contest: 1275

#include<iostream>
#include<string>
#include<cstdio>
#include<iomanip>
#include<cctype>
#include<cmath>
#include<map>
#include<algorithm>
#include<vector>
using namespace std;
map<char, string> yz;
map<string, char> hh;
vector<int> b;
bool cmp(int x, int y) {
	return x < y;
}
int main() {
	int t;
	int i, j;
	int a;
	while(cin >> t) {
		int sum = 0;
		if(t == 0)
			break;
		int flag = 0;
		for(i = 0; i < t; i++) {
			cin >> a;
			b.push_back(a);
			if(a < 2)
				flag = 1;
		}
		sort(b.begin(), b.end(), cmp);
		for(i = 1; i < b.size(); i++) {
			sum += b[i];
		}
		sum += 2;
		if(flag == 1)
			cout << -1 << endl;
		else {
			cout << sum << endl;
		}
		b.clear();
	}
	return 0;
}