#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  pair<long long, int> b[n];
  for (int i = 0; i < n; i++)
    cin >> b[i].first, b[i].second = i, b[i].first -= i;
  sort(b, b + n);
  int prev = 1000000000;
  long long ans = 0;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    if (b[i].first == prev)
      sum += b[i].first + b[i].second;
    else
      ans = max(ans, sum), sum = b[i].first + b[i].second, prev = b[i].first;
  }
  cout << max(ans, sum);
}
