#include<stdio.h>
#define MAX 100000

int n,k,ary[MAX];

int judge(int A){
  int i,count=0;
  for(i=0;i<k;i++){
    int s=0;
    while(s+ary[count]<=A){
      s+=ary[count];
      count++;
      if(count==n)return n;
    }
  }
  return count;
}

int calc(){
  int l=0,r=100000*10000,m,v;
  while(r-l>1){
    m=(l+r)/2;
    v=judge(m);
    if(v>=n)r=m;
    else l=m;
  }
  return r;
}

int main(){
  int i,ans;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&ary[i]);
  }
  ans=calc();
  printf("%d\n",ans);
  return 0;
}
    
  
  

