#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  long A[N], B[N + 1];
  B[0] = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    B[i + 1] = B[i] + A[i];
  }
  unsigned long ans = 0;
  sort(B, B + (N + 1));
  for (int i = 0; i <= N + 1; i++) {
    for (int j = i + 1; j <= N + 1; j++) {
      if (B[j] != B[i] || j == N + 1) {
        if (j == (N + 1)) {
          int diff = j - i + 1;
          if (diff > 1) {
            diff -= 1;
            ans += (diff * (diff + 1)) / 2;
          }
          i = j;
          break;
        }
        int diff = j - i;
        if (diff > 1) {
          diff -= 1;
          ans += (diff * (diff + 1)) / 2;
        }
        i = j;
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
