#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, sf, ss = 0;
  scanf("%d", &n);
  int a[n];
  sf = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    if (a[i] > sf) {
      sf = a[i];
      printf("SF=%d\n", sf);
    } else if (a[i] > ss) {
      ss = a[i];
      printf("SS=%d\n", ss);
    }
  }
  printf("SF=%d SS=%d\n", sf, ss);
  for (int i = 0; i < n; i++) {
    if (sf == a[i]) {
      printf("%d\n", ss);
    } else {
      printf("%d\n", sf);
    }
  }
  return 0;
}
