#include <stdio.h>

int main()
{
    int n;
    scanf("%d", &n);

    long long int a= 1;
    long long unsigned int b;
    int i;
    for (i = 0; i < n; i++) {
        scanf("%llu", &b);
        a *= b;
        printf("%d %llu\n", i,a);
        if (a > (long long int)1e18) {
            a = -1;
        }
    }
    if (a < 0)
        a = -1;

    printf("%llu\n", a);
    return 0;
}
