#include<bits/stdc++.h>
#define int long long

using namespace std;

signed main(){
  int A[100],N;

  cin >> N;
  for (int i=0;i<N;i++) {
    cin >> A[i];
  }

  int count = 0;
  int flag = 1;
  while(flag) {
    flag = 0;
    for (int i=N-1;i>0;i--) {
      if (A[i] < A[i-1]) {
        count++;
        int tmp = A[i];
        A[i] = A[i-1];
        A[i-1] = tmp;
        flag = 1;
      }
    }
  }
  
  for (int i=0;i<N-1;i++) {
    cout << A[i] << " ";
  }
  cout << A[N-1] << endl;
  cout << count << endl;
}
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

ll n, a[5];

int main(int argc, char **argv) {
	cin >> n;
	REP(i, 5) cin >> a[i];
	ll res = 0;
	REP(i, 5) res = max(res + 1, i + (n+a[i]-1)/a[i]);
	cout << res << endl;
	return 0;
}
