#include "bits/stdc++.h"
#include <random>
#include <time.h>

using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
#define llMAX 9223372036854775807LL
#define llMIN -9223372036854775808LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける


ll D=365;
ll PRMNUM=101;

vi c(26);
vi last(26,-1);
vvi dat(D, vi(26));  // N * M の2次元配列
vvi AAlist(D, vi(D));  // N * M の2次元配列
vvi ANSlist(PRMNUM, vi(D));  // N * M の2次元配列
ll PRM1=10;//1-1000
ll PRM2=5;//1-1000
ll PRM3=32;//1-100



ll calcscore(vi &Alist)
{
  for(ll i=0;i<26;i++){
    last[i]=-1;
  }
  

  ll sc=0;
  ll sct=0;
  ll l;
  ll id;
  ll factscore=0;
  for(ll i=0;i<D;i++){
    sc=-922337203685477580LL;
    for(ll j=0;j<26;j++){
      if (Alist[i]==j)continue;
      l=i-last[j];
      sct=l*c[j];
      factscore-=sct;
    }

    id=Alist[i];
    factscore+=dat[i][id];
    last[id]=i;
  }

  return factscore;
}



void makeseed(int xid,int startoffset)
{

  ll sc=0;
  ll sct=0;
  ll maxid=-1;
  ll factscore=0;
  
  for(ll i=0;i<26;i++){
    last[i]=startoffset-1;
  }

  for(ll i=startoffset;i<D;i++){
    sc=-922337203685477580LL;
    maxid=0;
    
    for(ll j=0;j<26;j++){
      ll l=i-last[j];
      
      l*=(l*16/PRM3+PRM1);
      sct=l*c[j]/PRM2;
      factscore-=sct;
      sct=dat[i][j]+sct;
      if (sc<sct){
        sc=sct;
        maxid=j;
      }
    }
    factscore+=sc;
    last[maxid]=i;
    AAlist[startoffset][i]=maxid;
    //cout<<(maxid+1)<<endl;
  }


}





int main(){  
  random_device seed_gen;
  ll tmp=time(NULL);
  mt19937 rnd(tmp);

  ll PRM1ARR[PRMNUM] = {207,121,442,227,476,60,693,110,202,461,236,221,109,307,175,248,552,76,135,192,279,167,510,474,349,411,625,332,75,130,303,142,423,98,20,194,21,56,101,84,52,132,42,223,119,92,103,32,233,319,298,350,425,79,261,33,159,361,901,130,68,182,517,497,109,420,164,318,57,27,355,584,409,198,146,239,454,412,236,144,84,233,516,120,167,5,461,180,6,328,346,428,442,84,41,407,586,204,306,161,607};
  ll PRM2ARR[PRMNUM] = {113,24,194,83,132,59,220,148,63,162,144,77,56,161,126,216,172,47,121,61,118,69,44,222,137,140,167,134,47,57,161,43,180,97,27,141,72,157,97,108,32,67,23,27,48,18,31,80,68,66,108,140,139,36,113,53,638,411,650,13,13,52,134,156,24,177,31,105,22,52,568,384,151,64,27,107,221,147,95,44,11,85,99,108,131,51,158,56,49,79,90,101,176,28,10,139,151,99,118,42,151};
  ll PRM3ARR[PRMNUM] = {2,15,1,2,1,5,6,1,3,1,1,2,3,1,1,2,1,2,1,3,1,2,11,1,1,1,1,1,2,2,1,6,1,1,4,1,2,1,1,1,19,9,18,20,11,10,3,1,3,2,1,1,1,4,1,2,1,2,14,10,26,6,1,1,7,1,6,1,6,2,1,2,19,11,7,2,1,2,3,5,11,1,8,1,1,2,1,4,2,18,9,2,1,5,17,1,1,9,1,4,1};


  ll ans=0;
  ll debug=0;//本番では0に
  cin>>ans;
  ll factscore=0;


  for(ll i=0;i<26;i++){
    cin>>c[i];
  }
  for(ll i=0;i<D;i++){
    for(ll j=0;j<26;j++){
      cin>>dat[i][j];
    }
  }


  ll score=-922337203685477580LL;
  ll ansid=0;






    if (debug==1)
    {
      ll maxsc=0;
      ll loopcnt=0;

      for(ll iii=0;iii<2000;iii++){
            loopcnt++;
            PRM1=rnd()%(rnd()%1000+1);
            PRM2=rnd()%(rnd()%1000+1)+1;
            PRM3=rnd()%(rnd()%32+1)+1;

            for(ll i=0;i<60;i++){
              makeseed(0,i);
            }
            for(ll i=1;i<60;i++){
              for(ll j=0;j<i;j++){
                AAlist[i][j]=AAlist[i-1][j];
              }
            }
            score=-922337203685477580LL;
            ansid=0;
            for(ll i=0;i<60;i++){
              if (score<calcscore(AAlist[i])){
                score=calcscore(AAlist[i]);
                ansid=i;
              }
            }
            if (maxsc<score){
              if (loopcnt<20000)maxsc=score;
            }else{
              iii--;
              continue;
            }
            cout<<PRM1<<"\t"<<PRM2<<"\t"<<PRM3<<"\t:\t"<<ansid<<"\t"<<score<<endl;
      }



    }
    



  



/*
  //random_device rnd;
  ll loopcnt=0;
  for(ll i=60;i<D;i++){
    ll aaa=rnd()%D;
    ll ref1=rnd()%60;
    ll ref2=rnd()%60;
    loopcnt++;
    if (loopcnt>18000)break;
    for(ll j=0;j<aaa;j++){
      AAlist[i][j]=AAlist[ref1][j];
    }
    
    for(ll j=aaa;j<D;j++){
      AAlist[i][j]=AAlist[ref2][j];
    }

    if (score>calcscore(AAlist[i]))
    {
      i--;
      continue;
    }
    
  }
*/


  if (debug==0)
  {
    for(ll k=0;k<PRMNUM;k++){
          //ここでPRM設定
          PRM1=PRM1ARR[k];
          PRM2=PRM2ARR[k];
          PRM3=PRM3ARR[k];
          for(ll i=0;i<60;i++){
            makeseed(0,i);
          }
          
          for(ll i=1;i<60;i++){
            for(ll j=0;j<i;j++){
              AAlist[i][j]=AAlist[i-1][j];
            }
          }

          score=-922337203685477580LL;
          ansid=0;
          for(ll i=0;i<60;i++){
            if (score<calcscore(AAlist[i])){
              score=calcscore(AAlist[i]);
              ansid=i;
            }
          }

          for(ll i=0;i<D;i++)
          {
            ANSlist[k][i]=AAlist[ansid][i];
          }
          
    }
  }















  score=-922337203685477580LL;
  ansid=0;
  for(ll i=0;i<PRMNUM;i++){
    if (score<calcscore(ANSlist[i])){
      score=calcscore(ANSlist[i]);
      ansid=i;
    }

    if (debug==1){
      cout<<calcscore(ANSlist[i])<<endl;
    }

  }



  if (debug==0)
  {
    for(ll i=0;i<D;i++){
      cout<<(ANSlist[ansid][i]+1)<<endl;
    }
  }else{
    cout<<calcscore(ANSlist[ansid])<<endl;
  }
    

  return 0;
}

/*
1万
36万
92万
*/

Measured memory_bytes: 5060