#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > beauty(6e5 + 2);
int main() {
  int n;
  cin >> n;
  vector<int> city(n);
  for (int i = 0; i < n; i++) {
    cin >> city[i];
    city[i] += n - i;
    beauty[city[i]].push_back(i);
  }
  long long maxBeauty = 0;
  long long currentBeauty = 0;
  for (int i = 0; i < beauty.size(); i++) {
    currentBeauty = 0;
    for (int j = 0; j < beauty[i].size(); j++) {
      int x = beauty[i][j];
      currentBeauty += x + i - n;
    }
    maxBeauty = max(maxBeauty, currentBeauty);
  }
  cout << maxBeauty << "\n";
  return 0;
}
