#include <bits/stdc++.h>
using namespace std;
const int N = 401;
int a[N], dp[N][N][N - 2];
int n, m, s, f, c, r;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = (1); i <= (n); ++i) scanf("%d", a + i);
  for (int s = (1); s <= (n); ++s)
    for (int f = (s); f <= (n); ++f) dp[s][f][0] = a[f] - a[s];
  for (int r = (1); r <= (n - 2); ++r)
    for (int s = (1); s <= (n - r - 1); ++s) {
      int j = s + r;
      for (int f = (s + r + 1); f <= (n); ++f) {
        for (; j < f && max(dp[s][j][r - 1], a[f] - a[j]) >
                            max(dp[s][j + 1][r - 1], a[f] - a[j + 1]);
             ++j)
          ;
        dp[s][f][r] = max(dp[s][j][r - 1], a[f] - a[j]);
      }
    }
  long long ans = 0;
  for (int i = (1); i <= (m); ++i) {
    scanf("%d%d%d%d", &s, &f, &c, &r);
    ans = max(ans, 1ll * dp[s][f][min(r, f - s - 1)] * c);
  }
  cout << ans << endl;
  return 0;
}
