#include <bits/stdc++.h>
using namespace std;
long long N;
vector<long long> A(200001, 0);
map<long long, long long> mp;
int main(void) {
  cin >> N;
  for (int i = 0; i < N; ++i) cin >> A[i];
  ++mp[0];
  long long sum = 0, ans = 0;
  for (int i = 0; i < N; ++i) {
    sum += A[i];
    ans += mp[sum];
    cout << sum << " " << mp[sum] << " " << ans << endl;
    ++mp[sum];
  }
  cout << ans << endl;
  return 0;
}
