#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int mex = 1000001;
long long int power(long long int a, int b) {
  long long int ans = 1, f = a;
  while (b) {
    if (b & 1) ans = (ans * f) % mod;
    b = b >> 1;
    f = (f * f) % mod;
  }
  return ans % mod;
}
long long int fact[mex + 1];
long long int ncr(int n, int k) {
  if (n < k) return 0;
  if (n == k) return 1;
  long long int ans = (fact[n] * power(fact[k], mod - 2)) % mod;
  ans = (ans * power(fact[n - k], mod - 2)) % mod;
  return ans % mod;
}
int main() {
  int n;
  cin >> n;
  long long int b[n];
  map<long long int, long long int> mp, mp1;
  for (int i = 0; i < n; i++) {
    cin >> b[i];
    b[i] -= i;
    mp[b[i]]++;
    mp1[b[i]] += i;
  }
  long long int ans = 0;
  for (auto it = mp.begin(); it != mp.end(); it++) {
    ans = max(ans, it->first * it->second + mp1[it->first]);
  }
  cout << ans << endl;
}
