#include<bits/stdc++.h>
#define f1(i, n) for(int i=1;i<=n;++i)
#define f0(i, n) for(int i=0;i<n;++i)
#define ull unsigned long long
#define ll long long
#define rev(a) reverse(a.begin(),a.end())
#define all(x) x.begin(),x.end()
#define so(A, n) sort(A+1, A+n+1)
using namespace std;
const int maxn = 3e5 + 1;
ll fi[100], A[maxn], size_fi = 0;
map<int, int> mp;
void tao() {
fi[1] = fi[2] = 1;
for (int i = 3; fi[i - 1] <= 1e9; ++i) {
fi[i] = fi[i - 1] + fi[i - 2];
++size_fi;
}
}
// neu A[i] = 1 thi A[i+1] co the = 1 hoac ko
bool checkFi(int l, int r) {
int iterFi = lower_bound(fi + 1, fi + size_fi + 1, A[l]) - fi;
int cnt1 = 0;
if(A[l] == 1 && A[l+1] != 1) iterFi++;
for (int i = l; i <= r; ++i) {
if (A[i] == 1) {
++cnt1;
if (cnt1 > 2) {
return false;
}
}
if (fi[iterFi] != A[i]) {
return false;
}
++iterFi;
}
return true;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
tao();
int n;
cin >> n;
f1(i, n) {
cin >> A[i];
mp[A[i]]++;
}
if (mp[A[1]] == n) {
if (binary_search(fi + 1, fi + size_fi + 1, A[1])) {
if (A[1] == 1) cout << 2 * n - 1;
else cout << n;
}
else {
cout << 0;
}
return 0;
}
int res = 0;
for (int i = 1; i <= n; ++i) {
for (int j = i; j <= n; ++j) {
if (binary_search(fi + 1, fi + size_fi + 1, A[i])) {
if (checkFi(i, j)) {
++res;
}
}
}
}
cout << res;
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KI2RlZmluZSBmMShpLCBuKSBmb3IoaW50IGk9MTtpPD1uOysraSkKI2RlZmluZSBmMChpLCBuKSBmb3IoaW50IGk9MDtpPG47KytpKQojZGVmaW5lIHVsbCB1bnNpZ25lZCBsb25nIGxvbmcKI2RlZmluZSBsbCBsb25nIGxvbmcKI2RlZmluZSByZXYoYSkgcmV2ZXJzZShhLmJlZ2luKCksYS5lbmQoKSkKI2RlZmluZSBhbGwoeCkgeC5iZWdpbigpLHguZW5kKCkKI2RlZmluZSBzbyhBLCBuKSBzb3J0KEErMSwgQStuKzEpCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmNvbnN0IGludCBtYXhuID0gM2U1ICsgMTsKbGwgZmlbMTAwXSwgQVttYXhuXSwgc2l6ZV9maSA9IDA7Cm1hcDxpbnQsIGludD4gbXA7CnZvaWQgdGFvKCkgewogICAgZmlbMV0gPSBmaVsyXSA9IDE7CiAgICBmb3IgKGludCBpID0gMzsgZmlbaSAtIDFdIDw9IDFlOTsgKytpKSB7CiAgICAgICAgZmlbaV0gPSBmaVtpIC0gMV0gKyBmaVtpIC0gMl07CiAgICAgICAgKytzaXplX2ZpOwogICAgfQp9Ci8vIG5ldSBBW2ldID0gMSB0aGkgQVtpKzFdIGNvIHRoZSA9IDEgaG9hYyBrbwpib29sIGNoZWNrRmkoaW50IGwsIGludCByKSB7CiAgICBpbnQgaXRlckZpID0gbG93ZXJfYm91bmQoZmkgKyAxLCBmaSArIHNpemVfZmkgKyAxLCBBW2xdKSAtIGZpOwogICAgaW50IGNudDEgPSAwOwogICAgaWYoQVtsXSA9PSAxICYmIEFbbCsxXSAhPSAxKSBpdGVyRmkrKzsKICAgIGZvciAoaW50IGkgPSBsOyBpIDw9IHI7ICsraSkgewogICAgICAgIGlmIChBW2ldID09IDEpIHsKICAgICAgICAgICAgKytjbnQxOwogICAgICAgICAgICBpZiAoY250MSA+IDIpIHsKICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoZmlbaXRlckZpXSAhPSBBW2ldKSB7CiAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICB9CiAgICAgICAgKytpdGVyRmk7CiAgICB9CiAgICByZXR1cm4gdHJ1ZTsKfQppbnQgbWFpbigpIHsKICAgIGlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oMCk7CiAgICBjaW4udGllKDApOwogICAgY291dC50aWUoMCk7CiAgICB0YW8oKTsKICAgIGludCBuOwogICAgY2luID4+IG47CiAgICBmMShpLCBuKSB7CiAgICAgICAgY2luID4+IEFbaV07CiAgICAgICAgbXBbQVtpXV0rKzsKICAgIH0KICAgIGlmIChtcFtBWzFdXSA9PSBuKSB7CiAgICAgICAgaWYgKGJpbmFyeV9zZWFyY2goZmkgKyAxLCBmaSArIHNpemVfZmkgKyAxLCBBWzFdKSkgewogICAgICAgICAgICBpZiAoQVsxXSA9PSAxKSBjb3V0IDw8IDIgKiBuIC0gMTsKICAgICAgICAgICAgZWxzZSBjb3V0IDw8IG47CiAgICAgICAgfQogICAgICAgIGVsc2UgewogICAgICAgICAgICBjb3V0IDw8IDA7CiAgICAgICAgfQogICAgICAgIHJldHVybiAwOwogICAgfQogICAgaW50IHJlcyA9IDA7CiAgICBmb3IgKGludCBpID0gMTsgaSA8PSBuOyArK2kpIHsKICAgICAgICBmb3IgKGludCBqID0gaTsgaiA8PSBuOyArK2opIHsKICAgICAgICAgICAgaWYgKGJpbmFyeV9zZWFyY2goZmkgKyAxLCBmaSArIHNpemVfZmkgKyAxLCBBW2ldKSkgewogICAgICAgICAgICAgICAgaWYgKGNoZWNrRmkoaSwgaikpIHsKICAgICAgICAgICAgICAgICAgICArK3JlczsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KICAgIGNvdXQgPDwgcmVzOwoKCiAgICByZXR1cm4gMDsKCgp9Cg==