#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  int temp,sum = 0;
  for (int i = 0; i < n; i++){
    cin >> temp;
    if (temp > 10){
      sum += temp -10;
    }
  }
  cout << sum << endl;

  return 0;
}
#include <bits/stdc++.h>

using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define all(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<ll,ll>;
using vi = vector<int>;

int n;
vector<vector<int>> a;

bool is_ok(int x){
    bool res = false;
    set<int> s;
    rep(i,n){
        int y = 0;
        rep(j,5){
            if(a[i][j] >= x){
                y |= 1<<j;
            }
        }
        s.insert(y);
    }
    for(auto i:s)for(auto j:s)for(auto k:s){
        if((i|j|k) == (1<<5)-1){
            res = true;
        }
    }
    return res;
}


int l=1,r=1009009009;

void bs(){
    if(r-l==1) return;

    int m = (l+r)/2;
    if(is_ok(m)){
        l = m;
    }
    else{
        r = m;
    }

    bs();
}

int main(){
    cin >> n;
    a.resize(n,vector<int>(5));

    rep(i,n)rep(j,5){
        cin >> a[i][j];
    }

    bs();

    cout << l << endl;

}