#include <stdio.h>
#include <stdlib.h>

int max_of(int arr[], int n, int except)
{
    int max;
    if (except == 0) {
        max = arr[1];
    } else {
        max = arr[0];
    }
    for (int i = 0; i < n; i++) {
        if (i != except && arr[i] > max) {
            max = arr[i];
        }
    }
    return max;
}

int main(void)
{
    int n;
    scanf("%d", &n);
    int* arr = calloc(n, sizeof(int));
    for (int i = 0; i < n; i++) {
        scanf("%d", &arr[i]);
    }

    for (int i = 0; i < n; i++) {
        printf("%d\n", max_of(arr, n, i));
    }
    return 0;
}
