#include <bits/stdc++.h>
using namespace std;
int arr[450];
int dist[405][405][405];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) scanf("%d", &arr[i]);
  for (int i = 1; i <= n; ++i) {
    for (int j = i; j <= n; ++j) {
      dist[0][i][j] = arr[j] - arr[i];
    }
  }
  for (int k = 1; k <= n; ++k) {
    for (int i = 1; i <= n; ++i) {
      int cur = i;
      for (int j = i; j <= n; ++j) {
        while (cur < j) {
          int x = dist[k - 1][i][cur];
          int y = arr[j] - arr[cur];
          int a = dist[k - 1][i][cur + 1];
          int b = arr[j] - arr[cur + 1];
          if (max(x, y) > max(a, b))
            cur++;
          else
            break;
        }
        dist[k][i][j] = max(dist[k - 1][i][cur], arr[j] - arr[cur]);
      }
    }
  }
  long long ans = 0;
  while (m--) {
    int s, f, c, r;
    scanf("%d%d%d%d", &s, &f, &c, &r);
    long long sum = 1ll * c * dist[r][s][f];
    ans = max(ans, sum);
  }
  cout << ans << endl;
}
