#include<stdio.h>
#include<stdlib.h>
int n;
int a[200];
int cmp1(const void *a, const void *b) {
return (*(int*)b - *(int*)a);
}
int main() {
while (scanf("%d", &n) != EOF) {
if (n == 0)break;
int sum = 0;
for (int i = 0; i < n; i++) {
scanf("%d", &a[i]);
}
qsort(a, n, sizeof(int), cmp1);
for (int i = 0; i < n; i++) {
if (a[i] < 2) {
sum = -1;
break;
}
if (i != n - 1) {
sum += a[i];
}
else {
sum += 2;
}
}
printf("%d\n", sum);
}
}