#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  int n;
  cin >> n;
  vector<int> b(n);
  for (int i = 0; i < n; ++i) {
    cin >> b[i];
  }
  map<int, int> mp;
  vector<ll> dp(n);
  for (int i = n - 1; i >= 0; --i) {
    dp[i] = b[i];
    auto it = mp.find(b[i] - i);
    if (it != mp.end()) {
      dp[i] += dp[it->second];
      it->second = i;
    } else {
      mp.emplace(b[i] - i, i);
    }
  }
  cout << *max_element(begin(dp), end(dp));
  return 0;
}
