#include <bits/stdc++.h>
using namespace std;
map<long long, pair<long long, long long> > q;
int n;
void solve() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    long long x;
    cin >> x;
    if (q.find(x - i) == q.end()) {
      q[x - i] = {0LL, 0LL};
    }
    q[x - i].first += (long long)i;
    ++q[x - i].second;
  }
  long long mx = 0;
  for (auto u : q) {
    long long a = u.first * u.second.second;
    long long b = u.second.first;
    mx = max(mx, a + b);
  }
  cout << mx;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  for (int i = 0; i < t; ++i) {
    solve();
  }
  return 0;
}
