#include <bits/stdc++.h>
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug& operator<<(const c&) {
    return *this;
  }
};
const double EPS = 1e-4;
void solve() {
  int n;
  cin >> n;
  vector<long long> a(n);
  vector<pair<long long, long long>> diff(n);
  for (long long i = 0; i < int(n); i++) cin >> a[i];
  for (long long i = 0; i < int(n); i++) diff[i] = {a[i] - i, i};
  sort(diff.begin(), diff.end());
  long long curr_sum = 0, res = 0;
  for (long long i = 1; i < n; ++i) {
    if (curr_sum == 0LL && diff[i].first == diff[i - 1].first) {
      curr_sum += (a[diff[i].second] + a[diff[i - 1].second]);
    } else if (diff[i].first == diff[i - 1].first) {
      curr_sum += a[diff[i].second];
    } else {
      curr_sum = 0;
    }
    res = max(res, curr_sum);
  }
  for (long long i = 0; i < int(n); i++) res = max(res, a[i]);
  cout << res;
  debug() << " ["
          << "diff"
             ": "
          << (diff) << "] ";
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
}
