Pagini recente » Cod sursa (job #2044424) | Cod sursa (job #1373246) | Rating powercut light (powercut) | Istoria paginii runda/simulare_oji_2023_clasele_11_12_14_martiee | Cod sursa (job #3276979)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("numarare.in");
ofstream fout("numarare.out");
int n, a[100003];
unsigned long long s, cnt;
int main()
{
int i, x, y;
fin >> n;
for (i = 1; i <= n; i++)
fin >> a[i];
for (i = 1; i < n; i++)
{
x = i;
y = i + 1;
s = a[x] + a[y];
while (x >= 1 && y <= n && a[x] + a[y] == s)
{
x--;
y++;
}
x++;
y--;
cnt += (y - x + 1) / 2;
}
fout << cnt << "\n";
return 0;
}