#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9;
const long long MOD = 1e9 + 7;
int main() {
  int n;
  cin >> n;
  long long s[n + 1];
  s[0] = 0;
  for (long long i = 1; i < (n + 1); i++) {
    int a;
    cin >> a;
    s[i] = a + s[i - 1];
  }
  sort(s, s + n + 1);
  int ans = 0;
  for (long long i = 0; i < (n + 1); i++) {
    int cnt = 1;
    for (long long j = i + 1; j < (n + 1); j++) {
      if (s[i] == s[j]) {
        i++;
        cnt++;
      } else {
        break;
      }
    }
    ans += cnt * (cnt - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
