#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#define ll long long
using namespace std;
const int maxn = 110;
const int inf = 0x3f3f3f3f;
int x, y, n;
int a[maxn];
int main()
{
while (scanf("%d", &n) && n)
{
int flag = 0;
for (int i = 1; i <= n; ++i) {
scanf("%d", &a[i]);
if (a[i] == 1||a[i]==0)
flag = 1;
}
if (flag)
printf("-1\n");
else
{
sort(a + 1, a + 1 + n);
reverse(a + 1, a + 1 + n);
int ans = 0;
for (int i = 1; i < n; ++i)
ans += a[i];
ans += 2;
printf("%d\n", ans);
}
}
return 0;
}