#include "stdafx.h" #include <iostream> #include <vector> #include <algorithm> #include <string> #include <set> #include <queue> #include <map> #include <sstream> #include <cstdio> #include <cstring> #include <numeric> #include <cmath> #include <iomanip> #include <deque> #include <bitset> //#include <unordered_set> //#include <unordered_map> //#include <bits/stdc++.h> //#include <xfunctional> #define ll long long #define PII pair<int, int> using namespace std; int dir[5][2] = { { 0,1 } ,{ 0,-1 },{ 1,0 },{ -1,0 } ,{ 0,0 } }; const long long INF = 0x7f7f7f7f7f7f7f7f; const int= INF 0x3f3f3f3f ; const Double PI = 3.14159265358979 ; const int MOD = + 1E9 . 7 ; const int MAXN = 2005 ; // IF (X <0 || X> Y = R & lt || <|| 0 Y> = C) / / 1000000000000000000 int a [ 200005 ]; struct node { int L; int R & lt; int W; } Tree [MAXN]; void Change ( int x, int a) { // value of x for the modified node tree [x] .w A + IF(X == 0 ) return ; // Representative updated Tree [X] .W + = A; Change (X / 2 , A); return ; } void Build ( int X, int left, int right) { // x is the current reference node Tree [x] .L = left; Tree [x] .r = right; IF (left == right) { Change ([left] x, a); // modify value of x is a [ left] return ; } Build ( 2 * X, left, (left + right) /2 ); Build ( 2 * X + . 1 , (left + right) / 2 + . 1 , right); // about each recursive calls return ; } int the Add ( int X, int left, int right) { // return interval and IF ((Tree [X] .L == left) && (Tree [X] .r == right)) // exactly equal, returns W return Tree [X] .W; int MID = (Tree [X] Tree + .L [X] .r) / 2 ; IF (right <= MID) // only may be present in the left son return the Add (X * 2, Left, right); IF (left> MID) // only may be present in the right son return the Add (X * 2 + . 1 , left, right); return the Add (X * 2 , left, MID) the Add + (X * 2 + . 1 , MID + . 1 , right); // the most common case, again divided into two } int main () { int size; CIN >> size; for ( int I = . 1 ; I <= size; I ++ ) CIN >> A [I]; Build ( . 1 ,1,size); int res = 0; for (int i = 1; i <= size; i++) { for (int j = 0; i + j <= size; j++) { if (add(1, i, i + j)) res++; } } cout << res << endl; return 0; }