#include <bits/stdc++.h>
using namespace std;
int dp[402][402][402];
int a[410];
int n, m;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i < n + 1; ++i) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = i; j <= n; ++j) {
      dp[i][j][0] = a[j] - a[i];
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int k = 0; k <= n; ++k) {
      int j = i + 1;
      int cur = i + 1;
      while (cur <= n) {
        if (dp[i][j][k] > a[cur] - a[j]) {
          dp[i][cur][k + 1] = max(a[cur] - a[j], dp[i][j][k]);
          cur++;
        } else {
          int t = a[cur] - a[j];
          while (dp[i][j][k] < a[cur] - a[j]) {
            t = min(t, max(dp[i][j][k], a[cur] - a[j]));
            j++;
          }
          t = min(t, max(dp[i][j][k], a[cur] - a[j]));
          dp[i][cur][k + 1] = t;
          cur++;
        }
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i < m; ++i) {
    int s, f, c, k;
    scanf("%d%d%d%d", &s, &f, &c, &k);
    long long t = (long long)dp[s][f][k] * c;
    ans = max(ans, t);
  }
  printf("%lld\n", ans);
}
