#include <bits/stdc++.h>
using namespace std;
long long holes[14];
int main() {
  long long zeroes = 0;
  for (long long i = 0; i < 14; i++) {
    cin >> holes[i];
    if (holes[i] == 0) zeroes++;
  }
  zeroes++;
  long long mx = 0;
  for (long long i = 0; i < 14; i++) {
    long long cnt = 0;
    if (holes[i] != 0) {
      long long a = holes[i] / 14;
      long long b = holes[i] % 14;
      if (a % 2 == 0) {
        cnt = zeroes * a;
        while (b) {
          if (holes[(i + b) % 14] == 0)
            cnt -= a;
          else
            cnt += (a + holes[(i + b) % 14] + 1);
          b--;
        }
      } else {
        cnt = a * (14 - zeroes);
        for (long long j = 0; j < 14; j++)
          if (i != j) cnt += holes[j];
        while (b) {
          if (holes[(i + b) % 14] == 0)
            cnt += a + 1;
          else
            cnt -= (a + holes[(i + b) % 14]);
          b--;
        }
      }
    }
    mx = max(cnt, mx);
  }
  cout << mx;
}
