#include <bits/stdc++.h>
using namespace std;
long long sum[600010];
long long n, b, ans = 0;
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> b;
    ans = max(ans, sum[i - b + 400000] += b);
  }
  cout << ans << endl;
  return 0;
}
