#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int max = 0;
  int scnd = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] > max) max = a[i];
  }
  for (int i = 0; i < n; i++) {
    if (a[i] != max && a[i] > scnd) scnd = a[i];
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (max == a[i]) cnt++;
  }
  cout << "cout = " << cnt << "\n";
  if (cnt != 1)
    for (int i = 0; i < n; i++) cout << max << "\n";
  else {
    for (int i = 0; i < n; i++) {
      if (a[i] != max)
        cout << max << "\n";
      else
        cout << scnd << "\n";
    }
  }
  return 0;
}
