#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define INF 1<<30

int score(int s) {
  if (s>21) return 0;
  else return s;
}

int main() {
  string s;
  while(getline(cin, s)) {
    //cout << s << endl;
    stringstream ss(s);
    int a;
    int sum = 0;
    int num1 = 0;
    while(ss >> a) {
      if (a > 10)
        a = 10;
      sum += a;
      if (a == 1)
        num1++;
    }
    if (a == 0) break;
    int ans = 0;
    REP(i,num1+1) {
      ans = max(ans, score(sum + i*10));
    }
    cout << ans << endl;
  }
}