#include<bits/stdc++.h>
using namespace std;
/* 変数名を被らせない
   デバッグコードを取り除く */
#define ANSWER(x) cout<<x<<endl
#define debug(x) cout<<#x<<": "<<x
const int MAX_INT = 1000000;
int dp[31];
int n;
int solve(int a);
int main(){
  while(1){
    memset(dp,-1,sizeof(dp));
    cin >> n;
    if(n==0)break;
    cout << (solve(n)/10-1)/365+1 << endl;
  }
}
int solve(int a){
  if(dp[a] != -1)return dp[a];
  else{
    if(a == 0)return 1;
    else if(a < 0)return 0;
    else return dp[a] = solve(a-1)+solve(a-2)+solve(a-3);
  }
}
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int n;
    while (cin >> n, n) {
        V a(n);
        rep(i, n) cin >> a[i];

        int ans = -1e9;
        rep(i, n) {
            int t = 0;
            rep2(j, i, n) {
                t += a[j];
                ans = max(ans, t);
            }
        }

        cout << ans << endl;
    }
}