#include <bits/stdc++.h>
using namespace std;
long long int b[400005] = {0};
long long int a[400005] = {0};
int main() {
  int n;
  cin >> n;
  int i;
  long long int temp, ans = 0, max;
  memset(b, 0, sizeof(b));
  memset(a, 0, sizeof(a));
  for (i = 1; i <= n; i++) {
    scanf("%lld", &temp);
    if (n == 1) {
      cout << temp;
      return 0;
    }
    if (temp - i >= 0) {
      b[temp - i] += temp;
    } else {
      a[i - temp] += temp;
    }
  }
  for (i = 0; i <= 400002; i++) {
    max = a[i] > b[i] ? a[i] : b[i];
    if (ans < max) ans = max;
  }
  cout << ans;
  return 0;
}
