#include <bits/stdc++.h>
using namespace std;
int main(int argc, char* argv[]) {
  int n;
  scanf("%d", &n);
  int A[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &A[i]);
  }
  int sagaku[n];
  sagaku[0] = 0;
  for (int i = 1; i < n; i++) {
    sagaku[i] = A[i] - A[i - 1];
  }
  int baibai[n];
  int state;
  if (sagaku[1] > sagaku[0]) {
    baibai[0] = 1;
    state = 1;
  } else if (sagaku[1] == sagaku[0]) {
    baibai[0] = 0;
    state = -1;
  } else if (sagaku[1] < sagaku[0]) {
    baibai[0] = 0;
    state = -1;
  }
  for (int i = 1; i < n - 1; i++) {
    if (state == 1 && sagaku[i + 1] > 0) {
      baibai[i] = 0;
    } else if (state == 1 && sagaku[i + 1] < 0) {
      baibai[i] = -1;
      state = -1;
    } else if (state == -1 && sagaku[i + 1] > 0) {
      baibai[i] = 1;
      state = 1;
    } else if (state == -1 && sagaku[i + 1] < 0) {
      baibai[i] = 0;
    } else {
      baibai[i] = 0;
    }
  }
  if (state == 1) {
    baibai[n - 1] = -1;
  } else if (state == 1) {
    baibai[n - 1] = 0;
  }
  long long money = 1000;
  int kabu = 0;
  for (int i = 0; i < n; i++) {
    if (baibai[i] == 1) {
      int kabu_to_buy = money / A[i];
      kabu += kabu_to_buy;
      money -= A[i] * kabu_to_buy;
      printf("%d %lld %d\n", baibai[i], money, kabu);
    } else if (baibai[i] == -1) {
      int kabu_to_sell = kabu;
      money = (long long)money + (long long)(A[i] * kabu_to_sell);
      kabu = 0;
      printf("%d %lld %d\n", baibai[i], money, kabu);
    }
  }
  printf("%lld\n", money);
}
